Link to home
Start Free TrialLog in
Avatar of roylam
roylam

asked on

file permission

I need to share a program (csh script) with other members of my group in a unix system (solaris).  Is there any way I could share without showing the source code?  I tried to make my HOME with permission 711 and the the program 711 as well.  But it doesn't seem working, "permission denied".  Any help will be appreciated.
Avatar of rbr
rbr

Try 755 at your HOME
Avatar of roylam

ASKER

I tried a few combinations of the permissions, and sofar only this work:
1) HOME 711 and file 755
2) HOME 755 and file 755 <- obvious after trying (1)

This, however, isn't what I intended, I don't want others have read access to my file -- just execution permission, ie file 711.

I have seen a program with permission somewhat like 711 but in the actual listing, ie ls -al, it has -rws--x--x
and the directory it belongs to is 755.  In this case, everyone can execute the program.  Any idea?

the file you are talking about is a setuid program.  You can't make scripts like this because the shell needs to be able to read the script in order to execute it, and also because many kernels do not let you make scripts setuid for security reasons.

Write a setuid (to your ID) wrapper in C and have the wrapper
close fd 0, and open the script O_RDONLY.   It should then call setuid(getuid()) to give away its sewtuid privs (don't forget to check for errors!).  It should then execv() /bin/csh with its complete argument string intact.

You can then "chmod go=" your csh script.

If you wanted to use stdin in the csh script, you will have to dup2(0, 4) in the C program, and replumb it with exec in a sh script, but IIRC csh doesn't support exec replumbing so you'd have to do that in a /bin/sh script and exec AGAIN to run the csh script.

Scripts in UNIX must at least have permission rx for those users
who should execute them. The se permissions even must be on the
directory containing the script. So you can't hide the text, no
way arround this.

The only solution executing a script without being read directly
by the user: sse JYoungman comment above.
I do think Youngman is correct.  If they don't have read permision then they can't execute.
Some shells DO allow setuid, though.  You can try chmod 4511 <yourscript>.  It works on my old ULTRIX system!
Avatar of roylam

ASKER

Thanks for all yours responses.

JYoungman's sounds good but also too technical.  So could you please give me a example.  The program I wrote basically dealing with awk, grep and cat.
roylam,
the permissions you describe (rws--x--x) are created by the chmod 4511 I described earlier.  Did you try that?
ASKER CERTIFIED SOLUTION
Avatar of elfie
elfie
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of roylam

ASKER

The program shc is working!

but sometime thereis a little problem:
#: command not found
Does that refer to a command that are executing in the script? if so, try to find out if the command is in the current path.
If it is not found, just extend the PATH with the correct directories.

If you are trying to execute a command inside the script with the dot command (.), it could be a problem. In that case you can try to include the other script in your executing script. (Change the . into a %include, and then you can use the C pre-processor to expand the script before using the shc program.
Avatar of roylam

ASKER

My csh script was working fine, but the compiled version sometimes produces strange output in addition to the normal output.  However, there is no problem at all after I changed the program into a sh script.

I think shc works better with sh script.