LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-01-2008, 03:42 AM   #1
arunabh_biswas
Member
 
Registered: Jun 2006
Posts: 92

Rep: Reputation: 16
Restrict editing of Shell scripts


Dear Experts,

Greeting of The Day !!

I've created few shell scripts to perform administration tasks. I also distributed those scripts to my subordinates for their use.

1) I want everybody can execute those scripts in their own (differnt) systems but cannot edit or view the codes what I've wrote in those scripts. As I've seen such kind of scripts somewhere with encrypted text inside.

2) I want to make such scripts which contains coloured menus, lines, text etc. Pls suggest me the detailed procedure to do the same.

Thanks in Advance.
 
Old 10-01-2008, 04:05 AM   #2
burschik
Member
 
Registered: Jul 2008
Posts: 159

Rep: Reputation: 31
So, your scripts are so bad that you don't want anyone else to see them, right?
 
Old 10-01-2008, 04:09 AM   #3
leadazide
Member
 
Registered: Apr 2004
Location: Germany
Distribution: SuSE 11.0, Ubuntu 7.10
Posts: 390

Rep: Reputation: 30
for the second, dialog is what you need, just take a look at its manpage. For the first, this depends whether the other users of the scripts have root access to the computers, but even if they have no root access, this might get tricky -- a chmod 711 script doesn't work, because the shell cannot open the script to execute as a user then -- perhaps restricting the scripts to be root only readable and then creating sudo rules to run the scripts as a root without the password (but obviously restricted to these scripts) might help.
 
Old 10-01-2008, 08:10 PM   #4
kirtimaan_bkn
Member
 
Registered: Aug 2004
Location: INDIA
Distribution: Various Distros
Posts: 203

Rep: Reputation: 31
Take a look at shc package. Using that you can compile your shell scripts, and then give the binary version to subordinates.
 
Old 10-03-2008, 12:44 PM   #5
arunabh_biswas
Member
 
Registered: Jun 2006
Posts: 92

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by burschik View Post
So, your scripts are so bad that you don't want anyone else to see them, right?
There is nothing funny in this man. Pls suggest some solution dear.
 
Old 10-03-2008, 12:50 PM   #6
arunabh_biswas
Member
 
Registered: Jun 2006
Posts: 92

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by leadazide View Post
for the second, dialog is what you need, just take a look at its manpage. For the first, this depends whether the other users of the scripts have root access to the computers, but even if they have no root access, this might get tricky -- a chmod 711 script doesn't work, because the shell cannot open the script to execute as a user then -- perhaps restricting the scripts to be root only readable and then creating sudo rules to run the scripts as a root without the password (but obviously restricted to these scripts) might help.

Thanks for taking u'r time to read my concern and your reply.
My concern is that I'm distributing my sys adm scripts in clear text to differnt persons in my office, I want every body can execute those shell scripts to perform the tasks but when they want to edit or view those files (i.e. vi filename), either they shouldn't able to edit these scripts or view the actual contents of the scripts.
Pls suggest in details.

Thanks.
 
Old 10-03-2008, 12:51 PM   #7
arunabh_biswas
Member
 
Registered: Jun 2006
Posts: 92

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by kirtimaan_bkn View Post
Take a look at shc package. Using that you can compile your shell scripts, and then give the binary version to subordinates.
thanks kirtimaan for u'r reply. Pls explain the above task how can perform the same to acheive my desired task.

Thanks.
 
Old 10-03-2008, 08:22 PM   #8
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
Quote:
There is nothing funny in this man. Pls suggest some solution dear.
I think he was being gently ironic. But he makes many points. The additional questions that I might pose are:
(1) Whats so special in those scripts?
(2) Do these scripts contain code examples taken from public forums but without the credits as some of them ask?
(3) Are these scripts your property or your company's?
(4) Why wouldn't you want your subordinates to read the scripts?

As to not being able to change the scripts, I agree. It's a genuine need.

If your team is operating exclusively in superuser mode, then first change it. Next give appropriate file and directory permissions to execute the scripts. This should do.

End
 
Old 10-04-2008, 01:38 PM   #9
arunabh_biswas
Member
 
Registered: Jun 2006
Posts: 92

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by AnanthaP View Post
I think he was being gently ironic. But he makes many points. The additional questions that I might pose are:
(1) Whats so special in those scripts?
(2) Do these scripts contain code examples taken from public forums but without the credits as some of them ask?
(3) Are these scripts your property or your company's?
(4) Why wouldn't you want your subordinates to read the scripts?

As to not being able to change the scripts, I agree. It's a genuine need.

If your team is operating exclusively in superuser mode, then first change it. Next give appropriate file and directory permissions to execute the scripts. This should do.

End
1) Whats so special in those scripts?
Ans: These scripts contains root previledged commands and I suspect that it might be used by other users or can be manipulate the scripts.

2) Do these scripts contain code examples taken from public forums but without the credits as some of them ask?
Ans: No, its only created by me. Its not derived or inspired by any script(s) from any forum.

(3) Are these scripts your property or your company's?
Ans : As I've mentioned earlier, these are only belongs to me purely.

(4) Why wouldn't you want your subordinates to read the scripts?
Ans: I suspect that they might change or modify those scripts and I want them as it is.

I hope its now all clear. Now pls do me the favour.
 
Old 10-04-2008, 03:18 PM   #10
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Scripts must be readable by the shell, and therefore by the user. If you encrypt them, there will always be a way around it since it has to be converted to text to interpret.

You could always write client/server programs, where the client runs on the user's machine and contacts the server to request execution of a script that the user doesn't have, then the server logs into the user's machine over ssh as root and executes it. That's a lot of work; more work than figuring out how to make the scripts safer.
ta0kira

PS You might be able to get away with doing a client/server thing with scripts and inetd (and maybe netcat.) I saw an example online somewhere, but I don't have the link anymore. You can also set up ssh to use RSA keys stored in ~ so that you don't have to put a password in the script. You'd have to set up the user's machines to accept that sort of login, though. Certainly more secure than giving out the scripts! As an extension of what I said before, anything that a user can execute can be reverse-engineered somehow, otherwise it couldn't be executed. The best thing to do is not allow the user to execute it; that way they don't have to have access to it.

Last edited by ta0kira; 10-04-2008 at 06:40 PM.
 
Old 10-04-2008, 09:18 PM   #11
abolishtheun
Member
 
Registered: Mar 2008
Posts: 183

Rep: Reputation: 31
Quote:
Originally Posted by arunabh_biswas View Post
1) Whats so special in those scripts?
Ans: These scripts contains root previledged commands and I suspect that it might be used by other users or can be manipulate the scripts.
Are you talking about setuid? Hopefully setuid on shell scripts is disabled on your machine.

Quote:
(4) Why wouldn't you want your subordinates to read the scripts?
Ans: I suspect that they might change or modify those scripts and I want them as it is.
Learn to use permissions.

Your question reeks of an amateur attempt to either spread malicious software or protect your source code.
 
Old 10-04-2008, 09:39 PM   #12
kirtimaan_bkn
Member
 
Registered: Aug 2004
Location: INDIA
Distribution: Various Distros
Posts: 203

Rep: Reputation: 31
Post

Quote:
Originally Posted by arunabh_biswas View Post
thanks kirtimaan for u'r reply. Pls explain the above task how can perform the same to acheive my desired task.

Thanks.
After getting shc package on your system, you can compile script using command

Code:
shc -v -r -f ur_shell_script
You can get detailed documentation at http://www.datsi.fi.upm.es/~frosal/sources/shc.html

And package itself is available at http://www.datsi.fi.upm.es/~frosal/

I expect that since you are writing scripts for system administration, your linux exposure is of at least intermediate level and you know how to compile and install programs.
 
Old 10-04-2008, 10:17 PM   #13
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by abolishtheun View Post
Learn to use permissions.
Permissions won't prevent copying and editing if the shell needs read access to execute the script.
Quote:
Originally Posted by abolishtheun View Post
Your question reeks of an amateur attempt to either spread malicious software or protect your source code.
Why would someone with the ability to execute things as root need to spread malicious code with a script? Why not just ssh as root and cause mayhem?
ta0kira

Last edited by ta0kira; 10-04-2008 at 10:18 PM.
 
Old 10-04-2008, 10:19 PM   #14
abolishtheun
Member
 
Registered: Mar 2008
Posts: 183

Rep: Reputation: 31
Quote:
Originally Posted by ta0kira View Post
Permissions won't prevent copying and editing if the shell needs read access to execute the script.
ta0kira
Yes but proper permissions and other security considerations will prevent them from doing something unauthorized to begin with.
 
Old 10-04-2008, 10:27 PM   #15
kirtimaan_bkn
Member
 
Registered: Aug 2004
Location: INDIA
Distribution: Various Distros
Posts: 203

Rep: Reputation: 31
I see this as a genuine requirement. Someone wrote a shell script which do something related to system administration. He need to give that to some one else for the purpose of execution. Now he don't want to share the 'code' (or secret, how he achieved to do that task with shell script) and thats why he want to restrict others to view or modify the script, but at the same time allow them to execute the script.

So in my view, it shouldn't be consider as either 'attempt to either spread malicious software' or 'bad scripts'.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to ssh from a shell script ? For ppl who can write shell scripts. thefountainhead100 Programming 14 10-22-2008 06:24 AM
Editing PDF from CLI with shell scripts hamtavs Linux - Software 1 04-27-2008 12:35 PM
Restrict a Shell Script to run from a shell bharaniks Linux - Security 7 08-26-2007 10:57 PM
restrict root shell using sudo ElectroLinux Linux - Security 2 03-30-2007 05:07 PM
Editing files from shell scripts? SirRobbin Linux - Newbie 6 03-23-2004 10:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration