当前位置:首页 » 服务器技术
开发技术指南» 文章正文
    引言: 直接使用geteuid()得到的是当前用户的编号,要得到用户名,
 

 

 ·出学asp的人的苦衷    »显示摘要«
    摘要:大家好! 我是出学asp的人,但总感觉很难,我不知道该怎样学才能学的快,我请教各位师姐师哥们,能否给我点建议?谢谢大家! ......
 ·aspect#应用 - 权限验证    »显示摘要«
    摘要:文章已转至以下地址: http://www.narchitecture.net/article/articledetails.aspx?id=jx8hwq ......


linux下使用系统调用取得当前用户名

直接使用geteuid()得到的是当前用户的编号,要得到用户名,还需要到/etc/passwd中去取得相应编号的用户名

#include <unistd.h> 【相关文章:自己动手编写Eclipse扩展点

程序如下 【扩展阅读:《dbXML 程序员手册_ 2.0_20

#include <stdio.h> 【扩展信息:大家来看Borland的Delphi9官

#include <sys/types.h>

#include <sys/stat.h>

#include <dirent.h>

#include <fcntl.h>

#define max 8192

#define umax 128

int slip(char *,char *,char*);

int char2int(char *);

int main()

{

  int fp;

  file* stream;

  uid_t cuser;

  char temp[umax][max];

  char fname;

  int i=0;

  char cname[20];

  char userid[10];

  cuser=geteuid();

  if((stream=fopen("/etc/passwd","r"))==null)exit(1);

  while((fname=fgetc(stream))!=eof)

   {

     temp[i][0]=fname;

     if(fgets(&temp[i++][1],max,stream)==null)exit(1);

   }

 for(i=0;i<umax&&temp[i][0];i++)

   {

     if(slip(temp[i],cname,userid)==0)exit(1);

     if(cuser==char2int(userid))break;


...   下一页
 ·aspect#的动态截入    »显示摘要«
    摘要:文章已转至以下地址:http://www.narchitecture.net/article/articledetails.aspx?id=mb6eni ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE