首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >tftpd作为root运行,尽管有显式选项“--用户tftp”。

tftpd作为root运行,尽管有显式选项“--用户tftp”。
EN

Unix & Linux用户
提问于 2014-02-01 17:53:19
回答 1查看 1.4K关注 0票数 2

我使用选项--user tftp启动我的tftp服务器,以便它以用户tftp而不是根用户的身份运行。但是,ps显示该进程仍然以root的形式运行。

代码语言:javascript
复制
ps aux| grep tftp
root      2542  0.0  0.0  14856   324 ?        Ss   Jan11   0:00 /usr/sbin/in.tftpd --listen --user tftp -vvvvv -s -p --ipv4 /srv/tftp

man tftpd说:

代码语言:javascript
复制
--user username, -u username
    Specify  the username which tftpd will run as; the default is "nobody".  
    The user ID, group ID, and (if possible on the platform) the supple‐
    mentary group IDs will be set to the ones specified in the system 
    permission database for this username.

用户tftp存在于我的系统上:

代码语言:javascript
复制
getent passwd | grep tftp
tftp:x:104:108:tftp daemon,,,:/srv/tftp:/bin/false

有什么可能是错的?

EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2014-02-01 19:22:53

从源代码来看,TFTP守护进程似乎只在连接完成后才会删除根权限。

编辑

在tftpd.c中,在某一点上有一个

代码语言:javascript
复制
while (1) {

行,并在循环的底部分叉子进程:

代码语言:javascript
复制
    /*
     * Now that we have read the request packet from the UDP
     * socket, we fork and go back to listening to the socket.
     */
    pid = fork();
    if (pid < 0) {
        syslog(LOG_ERR, "fork: %m");
        exit(EX_OSERR);     /* Return to inetd, just in case */
    } else if (pid == 0)
        break;              /* Child exit, parent loop */
}

/* Child process: handle the actual request here */

在下面的代码中,在某个点执行setuid调用以删除根权限

票数 4
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/112040

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档