【发布时间】:2012-01-20 18:02:52
【问题描述】:
所以我正在制作一个 debian 软件包,但是在复制所有文件后,我无法进行一些我想做的权限设置。它是一个网络应用程序并使用 libpcap。所以通常它需要root权限,但这是一个很大的安全问题。 (因为我的程序中的任何妥协都意味着对攻击者的完全 root 访问权限)所以相反,我们创建一个授予 pcap 权限的组,然后将安装用户添加到该组。
在makefile中它看起来像:
setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' /usr/bin/myProgram
groupadd -f myGroup
usermod -a -G myGroup $(SUDO_USER)
如果您运行“sudo make install”,这完全可以正常工作。但是当我尝试在 debian 包中的 postinst 脚本中执行此操作时,我得到了这个:
var/lib/dpkg/info/myProgram-1.0.postinst: line 13: SUDO_USER: command not found
Usage: usermod [options] LOGIN
Options:
-c, --comment COMMENT new value of the GECOS field
-d, --home HOME_DIR new home directory for the user account
-e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-f, --inactive INACTIVE set password inactive after expiration
to INACTIVE
-g, --gid GROUP force use GROUP as new primary group
-G, --groups GROUPS new list of supplementary GROUPS
-a, --append append the user to the supplemental GROUPS
mentioned by the -G option without removing
him/her from other groups
-h, --help display this help message and exit
-l, --login NEW_LOGIN new value of the login name
-L, --lock lock the user account
-m, --move-home move contents of the home directory to the
new location (use only with -d)
-o, --non-unique allow using duplicate (non-unique) UID
-p, --password PASSWORD use encrypted password for the new password
-s, --shell SHELL new login shell for the user account
-u, --uid UID new UID for the user account
-U, --unlock unlock the user account
-Z, --selinux-user new SELinux user mapping for the user account
显然是因为 $(SUDO_USER) 变量为空。这还怎么做?我必须提示用户输入他/她的用户名吗?这听起来非常难看。 或者也许你只是不应该在 debian 包中进行这种配置?
(IE:Wireshark 在这里也有同样的问题,但他们似乎只是把它留给用户,根本不会在安装时弄乱权限。)
【问题讨论】: