- 主题:[SMTH]关于 getuser() 函数使用方法求助
我想通过用户的ID来查询用户信息,用如下语句:
strcpy(uident,"wuweixin");
printf("%s\n",uident);
getuser(uident, &lookupuser);
可以编译通过,但是无法运行,提示:
Segmentation fault
程序放在 local_utl 下执行。
--
FROM 219.216.80.*
chdir(BBSHOME);
resolve_ucache();
这两句放头上,这样才能挂上shm的指针
可以参考别的local_utl程序,比如resetMailTotal
【 在 wuweixin (有颜色的猫) 的大作中提到: 】
: 我想通过用户的ID来查询用户信息,用如下语句:
: strcpy(uident,"wuweixin");
: printf("%s\n",uident);
: ...................
--
FROM 128.12.181.*
需要不需要使用 resolve_boards() 的?
【 在 atppp (Big Mouse) 的大作中提到: 】
: chdir(BBSHOME);
: resolve_ucache();
: 这两句放头上,这样才能挂上shm的指针
: ...................
--
FROM 219.216.80.*
你这三句程序不需要,但是一般也加上吧,反正这个执行应该很快的。
【 在 wuweixin (有颜色的猫) 的大作中提到: 】
: 需要不需要使用 resolve_boards() 的?
--
FROM 128.12.181.*
刚刚用 root 执行了一次,现在用 bbs 用户执行就这个样子:
Error! shmat 2 error! key = e6d.: Permission denied
【 在 atppp (Big Mouse) 的大作中提到: 】
: 你这三句程序不需要,但是一般也加上吧,反正这个执行应该很快的。
--
FROM 219.216.80.*
[root@bbs smthbbs-1.2]# ipcs
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 8290304 bbs 660 1024 2 dest
0x00000e74 17825793 bbs 660 1024 7
0x00000000 8355842 bbs 660 11204 2 dest
0x00000e70 17858563 bbs 660 5837252 6
0x00001194 17891332 bbs 660 4798384 4
0x00000e73 17924101 bbs 660 14578200 1
0x00000e72 17956870 bbs 660 224296 1
0x00002335 17989639 bbs 660 60008 1
0x00000e6d 13041674 root 660 11204 5
------ Semaphore Arrays --------
key semid owner perms nsems status
0x00054188 0 bbs 700 20
0x00000000 3735553 bbs 600 1
------ Message Queues --------
key msqid owner perms used-bytes messages
0x00000888 0 bbs 664 0 0
[root@bbs smthbbs-1.2]#
【 在 wuweixin (有颜色的猫) 的大作中提到: 】
: 刚刚用 root 执行了一次,现在用 bbs 用户执行就这个样子:
: Error! shmat 2 error! key = e6d.: Permission denied
--
FROM 219.216.80.*
e6d的owner变了,你可以把它改回来,或者清共享内存,重启动服务
如果你的外部程序一定要root执行,记得开头要
setuid(BBSUID);
setgid(BBSGID);
setreuid(BBSUID, BBSUID);
setregid(BBSGID, BBSGID);
【 在 wuweixin (有颜色的猫) 的大作中提到: 】
: [root@bbs smthbbs-1.2]# ipcs
: ------ Shared Memory Segments --------
: key shmid owner perms bytes nattch status
: ...................
--
FROM 128.12.181.*
什么叫 e6d 呀?
【 在 atppp (Big Mouse) 的大作中提到: 】
: e6d的owner变了,你可以把它改回来,或者清共享内存,重启动服务
: 如果你的外部程序一定要root执行,记得开头要
: setuid(BBSUID);
: ...................
--
FROM 219.216.80.*
0x00000e6d 13041674 root 660 11204 5
~~~
你那个错误信息不是写着 e6d permission denied
【 在 wuweixin (有颜色的猫) 的大作中提到: 】
: 什么叫 e6d 呀?
--
FROM 128.12.181.*
如果修改权限的话应该是修改 /home/bbs/bin 目录下文件的权限吧?
如果原先目标位置包含文件,则覆盖的文件权限不变吧?
连 lazybm 之类的都不可以用了 ……
【 在 atppp (Big Mouse) 的大作中提到: 】
: 0x00000e6d 13041674 root 660 11204 5
: ~~~
: 你那个错误信息不是写着 e6d permission denied
: ...................
--
FROM 219.216.80.*