setuid

Can i setuid for perl script?

我们两清 提交于 2019-12-30 23:04:13
问题 I made a perl script to change owner of a file owned by some other user. Script is complete. My administrator save that in /sbin directory and set uid for it using chmod u+s name_of_script. But when i run this script it gives me error that chown operation is not permitted. I made a C program and it works by following same steps. So my question is if setuid is working for perl then i should not get that error because C code did not give me any error. So can i setuid for perl script or i should

Can i setuid for perl script?

对着背影说爱祢 提交于 2019-12-30 23:04:01
问题 I made a perl script to change owner of a file owned by some other user. Script is complete. My administrator save that in /sbin directory and set uid for it using chmod u+s name_of_script. But when i run this script it gives me error that chown operation is not permitted. I made a C program and it works by following same steps. So my question is if setuid is working for perl then i should not get that error because C code did not give me any error. So can i setuid for perl script or i should

Why do I need setuid(0) within a setuid-root C program that calls an administrative program with system()?

删除回忆录丶 提交于 2019-12-23 07:12:30
问题 I had to do a dirty Linux hack for somebody so they could start a printer with the cupsenable printername shell command while being a non-root user. I didn't want them to be able to use the entirety of the cupsenable syntax as root, so I just wrote a C wrapper that sanitizes the input in argv[1] and calls system("cupsenable sanitizedprintername") . I made the program setuid root, but even so, cupsenable failed with "permission denied". Then I inserted a setuid(0) call before system() and, lo

Why do I need setuid(0) within a setuid-root C program that calls an administrative program with system()?

时光总嘲笑我的痴心妄想 提交于 2019-12-23 07:11:17
问题 I had to do a dirty Linux hack for somebody so they could start a printer with the cupsenable printername shell command while being a non-root user. I didn't want them to be able to use the entirety of the cupsenable syntax as root, so I just wrote a C wrapper that sanitizes the input in argv[1] and calls system("cupsenable sanitizedprintername") . I made the program setuid root, but even so, cupsenable failed with "permission denied". Then I inserted a setuid(0) call before system() and, lo

how to run cmd as root from apache (centOS)?

牧云@^-^@ 提交于 2019-12-23 04:43:35
问题 I'm trying to run the "useradd" command in CENTOS but I can't because I need root permissions. In my php_info(); I have '--disable-posix'. I have tried to re-install my PHP, and tried to enable the posix with yum and more options, but no luck. Can someone help me to make the posix enable or some other solutions? I notice that posix_getuid(); is working, but posix_setuid(); is not. Any solution? All I need to insert useradd into passwd(root) command by "user click". What is the best and most

Program can't load after setting the setuid bit on

谁说我不能喝 提交于 2019-12-22 04:48:11
问题 Consider this scenario in which an executable A.bin uses libY.so and libZ.so. A.c, Y.c and Z.c are all written in C. Z.c and Y.c are compiled into respective .so files. This is the directory structure of the files $home/bin/A.bin $home/lib/libY.so $home/lib/libZ.so When I run A.bin as normal user, A.bin runs normally as expected. Note: $LD_LIBRARY_PATH contains $home/lib I changed some code in A.c adding some functionality which needs admin privileges(like binding to a port less than 1000). I

stdbuf with setuid/capabilities

喜你入骨 提交于 2019-12-21 20:38:31
问题 I am reading output from another process which generates output (slow and infinite). Because I want to read this data in real-time I use "stdbuf -oL" (line-buffered, data is text). I do not have control of the generating process so I cannot modify the source to force flushing. So far stdbuf works just fine, however the process uses SOCK_RAW and needs either to be run as root, have setuid(0) or the cap_net_raw capability. When running as non-root with setuid or capabilities stdbuf seems to be

system() vs execve()

一个人想着一个人 提交于 2019-12-21 04:09:18
问题 Both system() and execve() can be used to execute another command inside a program. Why in set-UID programs, system() is dangerous, while execve() is safe ? 回答1: system will call the shell (sh) to execute the command sent as an argument. The problem with system because the shell behavior depends on the user who run the command. A small example: Creating a file test.c : #include <stdio.h> int main(void) { if (system ("ls") != 0) printf("Error!"); return 0; } Then: $ gcc test.c -o test $ sudo

Send the SIGHUP signal to a process in Perl

夙愿已清 提交于 2019-12-11 12:03:57
问题 I have a UNIX daemon, which wait of SIGHUP for refresh a data. I try to send a signal from the Perl script (under Apache www-data:www-data on the same server) by Proc::Killall ("killall('HUP', 'mydaemon');"), but I have no properly permissions. suid bit doesn't work too. 'kill -n HUP ' from shell are working. Does you have any idea to do this? 回答1: The usual work-around is to employ a »touch file« to indicate a reload, see Apache2::Reload for a real life example. Listen to notifications set

setuid() failing - operation not permitted

人走茶凉 提交于 2019-12-11 01:36:09
问题 changeIDs() is trying to use setuid() to change the effective user id but it always errors out and I'm not sure why. I have two users on computer. user is an admin with UID of 1000. The other standard user, user 2, has a UID of 1001. I want to use this program to set user2's effective UID to that of user1 (1000). Why does setuid() keep erroring? I made sure to run chmod u+s on the program executable as well and it still fails. rror with setuid() - errno : Operation not permitted Also, do you