- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- setuid problem
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2007 11:27 PM
08-01-2007 11:27 PM
i have a question ...
I use setuid with a my script for a user.
The script belong to oracle:oinstall and have this permission :
-rwsr-sr-x 1 oracle oinstall 22 Aug 8 12:49 pippo.sh
I launch this script with user test.
If i chek whith ps -ef :
ps -ef |grep -i pippo.sh
test 8484 8461 0 13:54:39 pts/tb 0:00 /bin/ksh ./pippo.sh
test 8504 8461 1 13:54:54 pts/tb 0:00 grep -i pippo.sh
I look that the process belong to test user and not oracle.
In SOLARIS this same test of setuid , and the process belong to oracle.
Thereis a procedure o configuration file or parameter in hpux for setuid to have a same solaris result
HELP me MANY POINT at all
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2007 11:44 PM
08-01-2007 11:44 PM
Re: setuid problem
HP-UX doesn't allow 'setuid' scripts by default. If you want to use this technique, you must create a 'setuid' C-wrapper around your script.
See here for more information:
http://docs.hp.com/en/B2355-60105/secure_sid_scripts.5.html
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2007 12:37 AM
08-02-2007 12:37 AM
Re: setuid problem
Can be found as part of the Internet Express,
installs in a minute, and another 3 minutes for editing your "wrapper" rule.
http://h20293.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=HPUXIEXP1111
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2007 01:17 AM
08-02-2007 01:17 AM
Re: setuid problem
but JAMES,
how i use the setuid script ???
help me step by step thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2007 01:48 AM
08-02-2007 01:48 AM
Re: setuid problem
If you wish to use the example provided in the manpage link in my post, copy the code therein into a secure place and change the define to specify *your* script's absolute path (e.g. '/usr/local/bin/pippo.sh'). If the modified code were called "pippo.c" compile it:
# cc ./pippo.c -o ./pippo
...Then set the setuid and setgid bits as yuo have shown in your post:
# chown oracle:dba ./pippo
# chmod 6555 ./pippo
Now, when you execute './pippo' you will be running a setuid/setgid shell script '/usr/local/bin/pippo.sh'.
As Ralph noted, 'sudo' is a good alternative to this, though.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2007 02:37 AM
08-02-2007 02:37 AM
Re: setuid problem
#include
#include
#include
#define SETUID_SCRIPT "/home/oracle/pippo.sh"
int main(int argc, char *const argv[])
{
if (strcmp(argv[1], SETUID_SCRIPT) == 0) {
execv(argv[1], argv+1);
perror(argv[0]);
} else {
fprintf(stderr, "%s is not a known setuid script\n",
argv[1] ? argv[1] : "unspecified-script" );
}
exit(1);
}
ollio-/home/oracle -> cc setto.c -o ./setto
(Bundled) cc: "setto.c", line 6: warning 5: "const" will become a keyword.
(Bundled) cc: "setto.c", line 6: error 1000: Unexpected symbol: "argv".
(Bundled) cc: "setto.c", line 6: error 1705: Function prototypes are an ANSI feature.
(Bundled) cc: "setto.c", line 8: error 1588: "argv" undefined.
(Bundled) cc: "setto.c", line 8: error 1528: Subscript expression must combine pointer and integer.
(Bundled) cc: "setto.c", line 9: error 1528: Subscript expression must combine pointer and integer.
(Bundled) cc: "setto.c", line 10: error 1528: Subscript expression must combine pointer and integer.
(Bundled) cc: "setto.c", line 12: error 1588: "stderr" undefined.
(Bundled) cc: "setto.c", line 13: error 1528: Subscript expression must combine pointer and integer.
(Bundled) cc: "setto.c", line 13: error 1528: Subscript expression must combine pointer and integer.
(Bundled) cc: "setto.c", line 13: error 1552: First expression of ?: must be arithmetic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2007 02:40 AM
08-02-2007 02:40 AM
Re: setuid problem
In the strictest sense, setuid scripts should have never been functional because scripts are not true executables but rather data files for an executable --- the shell in this case.
As noted, you will need to either create a wrapper or put your command under the control of sudo. Sudo is the much better choice because you have great control over who is allowed to execute what commands and the activity is logged.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2007 03:08 AM
08-02-2007 03:08 AM
SolutionYour compilation problem is due to the fact that you don't have an Ansi C compiler; only the bundled one offered free.
#include
#include
#include
#define SETUID_SCRIPT "/home/oracle/pippo.sh"
main(argc, argv)
int argc;
char **argv;
{
if (strcmp(argv[1], SETUID_SCRIPT) == 0) {
execv(argv[1], argv+1);
perror(argv[0]);
} else {
printf("%s is not a known setuid script\n",
argv[1] ? argv[1] : "unspecified-script" );
}
exit(1);
}
...should compile for you. If you compile the code and name it 'pippo' then you run it like:
# ./pippo /home/oracle/pippo.sh
...having 'chmod'ed the 'pippo' executable as I first noted.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2007 03:16 AM
08-02-2007 03:16 AM
Re: setuid problem
it's not enough to have just the kernel compiler to compile this piece of code.
If you tranfer the source file to be 'Kernighan-Richie'-compliant, it will do.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2007 09:04 PM
08-02-2007 09:04 PM
Re: setuid problem
Note: K&R isn't supported on Integrity.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2007 09:57 PM
08-02-2007 09:57 PM
Re: setuid problem
2) the c script work but if i do ps:
$ id
uid=114(test) gid=20(users)
$ cd /home/oracle
$ ll
total 112
drwxr-xr-x 2 oracle oinstall 96 Aug 9 10:16 TAR
-rw-rw-rw- 1 root sys 422 Aug 8 17:01 ninni.c
-rw------- 1 root sys 0 Aug 8 13:05 nohup.out
-r-sr-xr-x 1 oracle oinstall 20480 Aug 9 11:34 pippo
-rw-rw-rw- 1 root sys 423 Aug 9 11:34 pippo.c
-rwsr-xr-x 1 oracle oinstall 22 Aug 8 12:49 pippo.sh
-rw-rw-rw- 1 root sys 422 Aug 8 16:55 setto.c
$ ./pippo /home/oracle/pippo.sh &
[1] 20133
ps -ef |grep -i pippo
test 20133 20114 0 12:24:15 pts/ta 0:00 /bin/ksh /home/oracle/pippo.sh
test 20141 20114 1 12:24:31 pts/ta 0:00 grep -i pippo
i need that this process process belong to oracle user ...
thanks
and a poin at the finish .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2007 10:16 PM
08-02-2007 10:16 PM
Re: setuid problem
the ps-output may be meaningless and NOT telling you the EUID. Add something like
rm -f /tmp/newfile
touch /tmp/newfile
ls -l /tmp/newfile
in your script and check the permissions for correctness.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2007 10:20 PM
08-02-2007 10:20 PM
Re: setuid problem
>i need that this process process belong to oracle user
It does. ps(1) returns the original real user and not the effective user.
Have your script use id(1) to check.
Note the ps -u option works differently depending on whether you use UNIX95= or not.
Note you can customize ps with UNIX95= by displaying both USER and RUSER.
$ UNIX95= ps -ef -opid,user,ruser,args
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2007 10:27 PM
08-02-2007 10:27 PM
Re: setuid problem
$ UNIX95= ps -ef -opid,user,ruser,args
Hmm, it seems that just by using UNIX95= ps(1) displays the effective ID. I don't see a difference between user and ruser when I use a sudo-like tool to run that ps. I just get root. Hmm, it happens even without UNIX95??)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2007 02:31 AM
08-03-2007 02:31 AM