Register
It is currently Mon Dec 22, 2014 5:38 am

simple bash script permission


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Wed Feb 17, 2010 12:48 pm   

Joined: Wed Feb 17, 2010 12:47 pm
Posts: 1
I have a bash script, but it needs to have a simple protection with password.
So if a user wants to run the script , there should be a kdialog to asks for a password.If the password is correct the script starts to run.
It should not be the passord of root or another admin user.Just a password in the script of taken from a password file that i create myself.
The reasion is that I wont have to configure rights on the linux system.It is not a dangerous script, just for configuring sound devices.


Top
 Profile  
 PostPosted: Thu Feb 18, 2010 5:36 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
This is a demo of an ultra basic password request, it likely has several issues but it should run as is;

set a password;
Code:
echo 'mypass' | md5sum | awk '{ print $1 }' > temp/passfile


ask for the password and check it;
Code:
read -sp 'passwd: ' passinput
blx=$(echo "$passinput" | md5sum | awk '{ print $1 }')
if [ "$blx" == "$(cat temp/passfile)" ]
  then echo yes
fi


This has the advantage that the password is not stored, only the md5sum of the password.


Top
 Profile  
 PostPosted: Thu Feb 18, 2010 5:37 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
I'm sorry I missed that you intended to have a kdialog, I have no idea how to use that but maybe you can adapt the principle to suit.


Top
 Profile  
 PostPosted: Mon Feb 22, 2010 7:42 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 673
Location: Des Moines, Iowa
DarthWavy wrote:
This is a demo of an ultra basic password request, it likely has several issues but it should run as is;

set a password;
Code:
echo 'mypass' | md5sum | awk '{ print $1 }' > temp/passfile


ask for the password and check it;
Code:
read -sp 'passwd: ' passinput
blx=$(echo "$passinput" | md5sum | awk '{ print $1 }')
if [ "$blx" == "$(cat temp/passfile)" ]
  then echo yes
fi



THAT is very cool... I've never thought of doing that before... pretty cool :)
This has the advantage that the password is not stored, only the md5sum of the password.


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP