- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: su within a ksh script?
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
01-27-2000 07:57 AM
01-27-2000 07:57 AM
su within a ksh script?
I would like to allow regular users database access under the very-controlled
script environment without allowing them this access outside of the script. If
I could switch users back & forth within the script, I could provide this
limited service.
Thanks for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2000 08:43 AM
01-27-2000 08:43 AM
Re: su within a ksh script?
unpredictable results. Some people do it and never report problems, but most of
the problems I've seen were related to database access.
Instead, consider using a compiled program with the appropriate access rights
that the users can execute. This way they can't do anything the script wasn't
written to do.
If you can't write a program to do it, you can use a script with the setuid bit
set. This will allow users to run the script, which will then execute as if it
were being run by the owner of the script itself.
This can lead to a security risk though, because anyone who can edit the script
or otherwise manipulate things could potentially gain unexpected access. This
would have to be done on purpose by the user, of course, and shouldn't happen
by accident.
For more info, see the man page for "chmod" and read about the "s" bit (mode
4000, or u+s).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2000 01:01 AM
01-28-2000 01:01 AM
Re: su within a ksh script?
following results:
Here's a look at the small test script. To be able to properly execute the
real script any user that runs it must assume the user id of user1.
[user2] /usr/local/bin> more test1.scr
id
exit
test1.scr: END
With normal permissions, the script returns the current uid 202(user2).
[user2] /usr/local/bin> ll test1.scr
-rwxr-xr-x 1 user1 users 8 Jan 28 09:30 test1.scr
[user2] /usr/local/bin> test1.scr
uid=202(user2) gid=20(users)
After chmod u+s, but with the same results.
[user2] /usr/local/bin> ll test1.scr
-rwsr-xr-x 1 user1 users 8 Jan 28 09:30 test1.scr
[user2] /usr/local/bin> test1.scr
uid=202(user2) gid=20(users)
For kicks I tried chmod 4000.....
[user2] /usr/local/bin> ll test1.scr
---S------ 1 user1 users 8 Jan 28 09:30 test1.scr
[user2] /usr/local/bin> test1.scr
ksh: test1.scr: cannot execute
Here's the needed results...but using su on screen.
[user2] /usr/local/bin> su user1
Password:
[user2] /usr/local/bin> test1.scr
uid=201(user1) gid=20(users)
I'm even willing to try the (not recommended) su inside the script, if it has a
possibility of working. I just need to know how to do it.
Any other ideas out there?
Thanks again for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2000 08:52 AM
01-31-2000 08:52 AM
Re: su within a ksh script?
think using the SUID will return the GID you are looking for. What it does is
allow the script to run stuff as if it had the same permissions it would have
if launched by the owner of the script. If your goal is to allow users access
to something they can't run manually, then you should be set. If you actually
need the "id" command to return a specific value, I don't know what you'll need
to do.
Note that the large "S" after your chmod 4000 indicates that there is no "x"
under it, so execute permission is denied.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2000 03:52 AM
02-01-2000 03:52 AM
Re: su within a ksh script?
superuser. Place all the commands you would like run in the script, the use:
chown root:sys filename (or appropriate values) then I prefer to use chmod 4711
filename. This will give the user the ability to execute the script as if they
were su, but will disallow read/write access to all but the su. I've used this
method, to allow the average user the ability to reboot the system. Hopefully
this helps.
Doug
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2000 09:03 AM
02-01-2000 09:03 AM
Re: su within a ksh script?
The sticky bit is a different bit (the last one) and is used to tell the system
to keep the program "stuck" in memory after the first time it is executed.
That's where it gets its name! It's also known as the "save-text-image on file
execution" bit.
There's also a SET-Group-ID bit. More info on these bits can be found in the
man page for CHMOD(1) under the section "Miscellaneous mode bits".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2000 07:40 AM
02-03-2000 07:40 AM
Re: su within a ksh script?
with only the actual su command within the script. Dan, you mentioned in your
first reply "It is not recommended that you use su inside a script because it
can cause unpredictable results". I would like to test using the su command
inside my script, but simply don't know how to implement it.
How do you answer a prompt and press the enter key within a script? (Using su
online forces you to type the password, then press enter).
Thanks again for your thoughts.