t**********s 发帖数: 930 | 1 【 以下文字转载自 Linux 讨论区 】
发信人: tennisalways (tennisforever), 信区: Linux
标 题: Linux下如何限制一个命令只能在登陆为指定用户下才能运行?
发信站: BBS 未名空间站 (Wed Jan 27 22:24:13 2010, 美东)
我有个Perl script,希望只有登陆为用户A时才能运行,而登陆为其他用户时无法运行。
是不是可以通过设定文件属性达到这个目的?
对Linux不是很熟,谢谢。 |
r***e 发帖数: 10135 | 2 chmod 744
行。
【在 t**********s 的大作中提到】 : 【 以下文字转载自 Linux 讨论区 】 : 发信人: tennisalways (tennisforever), 信区: Linux : 标 题: Linux下如何限制一个命令只能在登陆为指定用户下才能运行? : 发信站: BBS 未名空间站 (Wed Jan 27 22:24:13 2010, 美东) : 我有个Perl script,希望只有登陆为用户A时才能运行,而登陆为其他用户时无法运行。 : 是不是可以通过设定文件属性达到这个目的? : 对Linux不是很熟,谢谢。
|
n*****m 发帖数: 73 | 3 chown A file
chmod 744 file
【在 r***e 的大作中提到】 : chmod 744 : : 行。
|
c****j 发帖数: 258 | 4 S/he is asking about a perl script not a binary exec, even you revoke 001
permision for other users, they can still run the script by calling "perl
script_file".
a dirty way is to add getuid in the script, and stop the execution when it's
not A.
another way is to revoke 100 permission from other users, so it becomes 700 mode
【在 n*****m 的大作中提到】 : chown A file : chmod 744 file
|
t**********s 发帖数: 930 | 5 Not good enough.
Root can still run it.
I want to block it from every one else except A.
【在 n*****m 的大作中提到】 : chown A file : chmod 744 file
|
t*****k 发帖数: 1 | 6 root have access to all files without any limitations. I don't think it is
possible.
【在 t**********s 的大作中提到】 : Not good enough. : Root can still run it. : I want to block it from every one else except A.
|
t******r 发帖数: 88 | 7 可以只允许root su/sudo
【在 t*****k 的大作中提到】 : root have access to all files without any limitations. I don't think it is : possible.
|
a****l 发帖数: 8211 | 8 how about setting that file to be only readable by that user?
行。
【在 t**********s 的大作中提到】 : Not good enough. : Root can still run it. : I want to block it from every one else except A.
|
c********e 发帖数: 383 | 9 I think you have to change your script to do so. |