![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| FTP File Permission | raybakh | AIX | 1 | 07-04-2006 05:11 AM |
| File Permission | KhawHL | UNIX for Advanced & Expert Users | 2 | 05-24-2006 02:05 AM |
| The file permission | ust | Shell Programming and Scripting | 1 | 05-12-2005 06:01 AM |
| The file permission | ust | UNIX for Dummies Questions & Answers | 2 | 05-05-2005 06:18 AM |
| Log file - permission | ajkiruba | UNIX for Advanced & Expert Users | 6 | 04-24-2002 09:42 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
File Permission
I have written a shell script function, this function reads a encrypted a file and does some processing. I want to give execute permissions to others but I don't want to give read access to the shell script function. Since the shell script function know how to open the encrypted file so that's why I don't want to allow others to see the content of shell script file. I want this kind of permissions (rwxr-x--x myscript.ksh)
The problem is other users get permission problem, since shell can't read file so it can't execute as well. Is there any easy method so that the others can execute but can't read the shell script file. I know writing C programme will solve this problem but I am not good in writing C programme. Thanks Sanjay |
| Forum Sponsor | ||
|
|
|
|||
|
Yeah, that's always a tricky one...
You can create a wrapper script for your original script with setuid permissions. Ie: wrapperscript.sh has 4755 permissions and your readme.sh script has 111 permissions. You just need to do some checksumming or validation when using setuid wrapper scripts as it can open up security holes if not done properly. A very simple example would be to make sure you use the fully qualified path to your file reader script... That's all I can think of off the top of my head Good luck.
__________________
Potatoes grow in the ground. |
|
|||
|
Thanks Guys,
I was able to write a C wrapper script and it looks like it works perfect. Sanjay #include <stdlib.h> #include <stdio.h> #include <string.h> /********************************************** This is the wrapper script How to Compile : gcc f_getSQLPLUS.c -o f_getSQLPLUS : chmod 4711 f_getSQLPLUS ***********************************************/ int main(int argc, char *argv[]) { char argbuf[4096] = ". /opt/app/oracle/local/bin/oralib.ksh ; "; int i; for (i = 0; i < argc ; i++) { strcat(argbuf,argv[i]); strcat(argbuf, " "); } //printf("%s", argbuf); system(argbuf); } Quote:
|
|
|||
|
Quote:
-rwsr-xr-x 1 root other 123 Mar 29 15:19 a ---x------ 1 root other 119 Mar 29 15:19 b Script A is as follows: #!/bin/ksh echo "\nIn A" echo "id --- \c" id echo "whoami --- \c" /usr/ucb/whoami echo "who am i --- \c" who am i ./b Last line, you'll see that A calls B. Script B is as follows: #!/bin/ksh echo "\nin B" echo "id --- \c" id echo "whoami --- \c" /usr/ucb/whoami echo "who am i --- \c" who am i Changing to login testme and attempting to run B: $ ./b ksh: ./b: cannot execute $ And running A: $ ./a In A id --- uid=100(testme) gid=20(testme) euid=0(root) whoami --- root who am i --- root pts/7 Mar 29 15:10 (machine hidden) in B id --- uid=100(testme) gid=20(testme) euid=0(root) whoami --- root who am i --- root pts/7 Mar 29 15:10 (machine name) $ Fairly simple and quick test to setup Glad you got your script working...
__________________
Potatoes grow in the ground. |
|
||||
|
Quote:
I tried the following script also setuid to root and invoked by an ordinary user: Code:
#! /usr/bin/ksh sleep 999 exit 0 |