473,387 Members | 3,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Activating SU in a script and not having to enter the password.

I'm trying to make it to where I can change the permissions of a file so that anyone can read sed file; however the file is being printed by the root & can only be changed via the root. I created a script but it still needs a password & I would like it to where a password is not required.
My Script

for file in /home/mmkmmk3/history/*.txt
do
chmod 777 $file >> results.out
done

Now is there anyway I can bypass having to enter in any password? I know the risk of an automated root password enter via a script so I don't need a lecture on that, mind you. A nice fix would be nice!
Jan 31 '13 #1
10 1839
sicarie
4,677 Expert Mod 4TB
Not familiar with a way to do that off the top of my head, but a few workarounds might be:

1) Use a cron job under root to run every so often (nightly, hourly, your preferred interval) and reset the permissions in that directory chmod 777 /home/mmkmmk3/history/*.txt

2) use another system with SSH keys set up so there's no authentication, and run it as root from there

and a horribly insecure workaround would be

3) reset root's umask to have ------rwx set This will mean that ANY file created by root will be visible to every user on the system and can easily create vulnerabilities
Feb 1 '13 #2
That third one would work, could you explain it some more. I understand the risk but these files are worthless to anyone else.

The first one, I don't know what a cron job is, could you also expand on that. Sorry for being so unfamiliar
Feb 5 '13 #3
zmbd
5,501 Expert Mod 4TB
CRON is the scheduled task manager for UNIX based systems:
CRON quick reference
and a much more in-depth tutorial
Linux tip: Job scheduling with cron...

Have you looked at Group settings over a directory.
Linux Files and File Permission (you can find the same information via the IBM link, just click thru) Redirect the output of the file in question to the correct folder and set the group rights:
Directory Set Group ID
If the setgid bit on a directory entry is set, files in that directory will have the group ownership as the directory, instead of than the group of the user that created the file.

This attribute is helpful when several users need access to certain files. If the users work in a directory with the setgid attribute set then any files created in the directory by any of the users will have the permission of the group. For example, the administrator can create a group called spcprj and add the users Kathy and Mark to the group spcprj. The directory spcprjdir can be created with the set GID bit set and Kathy and Mark although in different primary groups can work in the directory and have full access to all files in that directory, but still not be able to access files in each other's primary group.





and a horribly insecure workaround would be
Is an understatement!

IMHO: Fragglehaggle: Stay the [insert foot here] away from that last option. I guarantee that if that file is important to you for anything other than making paper airplanes, someone else will want it too, more importantly is that you open the ROOT to potential hacks - that would have been a dream mask back in the day! };-)
Feb 6 '13 #4
It's simply homework for my Linux class. I don't think anyone else wants it, much less would I care if they took it.

Thanks for the link to the cron task. I'll check it out soon!
Feb 6 '13 #5
zmbd
5,501 Expert Mod 4TB
Homework is valuable.
To tell my age a tad... 20+ years ago while at university, my CompSci account was hacked and the individual d/l the code, del from my account, and attempted to use my code for his classwork; sucked for him that I'd already compiled and turned the code and program into the prof about an hour before he did... funny, is that he had my Beta Code.
20 years, and when I go to visit, Dr.P and I still get a laugh over a beer - and he's the one telling the story.

Oh, and we cross posted... I add the group/directory level information.
Feb 6 '13 #6
sicarie
4,677 Expert Mod 4TB
zmbd - I totally forgot about the sticky bit - great idea!

Fragglehaggle - zmbd is totally right - both other options are so much better than option 3. Re-setting root's umask is something you do on a vm you know you're going to wipe out as soon as you're done working on it - it's really a last-ditch option.
Feb 6 '13 #7
These are just simple lab projects that are usually just testing certain commands, and the affects of using different variables & strings. Comm. College. I do want to use a VM it would be nice. I'd rather have it & not need it than need it & not have it.
Feb 6 '13 #8
sicarie
4,677 Expert Mod 4TB
Speaking as a teacher of Linux in a community college, I can definitely say learning to work around without the umask will be MUCH more valuable - using the sticky bit, cron, or pre-shared auth.

If you really want to learn umasks, then set the umask for the individual user and validation your permissions, not root.

I think the sticky bit is the best option - learn how to limit permissions - and the cron is the second best - you can set the interval to as low as every minute if you want, so you will just have to wait 60 seconds if your command fails on permissions...
Feb 6 '13 #9
I do respect & appreciate all the info, but I'd still rather have it & not need it than otherwise.
Feb 6 '13 #10
sicarie
4,677 Expert Mod 4TB
Sure, it would be modifying the umask option in the user's profile file - I believe it's in the octal notation, so 000 through 777 depending on your preferred permissions, the last number being your desired setting (this is assuming that the folder/path has the permissions to allow access as well).
Feb 6 '13 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: JCO | last post by:
How's come when I press the enter key, I can't get it to execute the correct password. It seems that I'm forced to press the button. I want to be able to do both. How is this done?
3
by: Noel S Pamfree | last post by:
Problem 1 ======= I need to create a page for a friend who operates a school website. She needs to set up a page so that only the Governors can access it. I thought I'd try to use JavaScript to...
2
by: jonathan184 | last post by:
Hi I am try to create a script to login EMS admin tool *JMS* Now the admin account has a blank password. so if i login normal usually i type this: i press enter username(ADMIN) prompt - i...
8
by: sabby | last post by:
I want to use the getline() so that i can enter a entire name in on line. (with spaces) The prob is that i am initializing the variable as "N/A" and saving it to a text file. it is declared as a...
1
by: Peterwkc | last post by:
hello all expert database administrator, i truly new to access. I want to develop a website where the password and re-enter password must be same. How to i validate this in access or i need ti...
10
George Lft
by: George Lft | last post by:
In my new registration page, i'm trying to create a double entry password / username to validate their entry . haven't decided which one, probably i'll go just with the password . What is the PHP...
4
by: Cecil1984 | last post by:
hi everyone could anyone help to conform the password, my script is following #!/usr/bin/perl use Getopt::Std; getopt('a:u:'); # First command switch, adding a user. if ($opt_a)
1
by: llastein | last post by:
Want to pass username selected from a dynamic list, after entering password. That is opening a page with the parameter username., Have a script to pick the right username but want to enter password...
0
by: matt753 | last post by:
Just set up a server running Windows home server, ~10 computers attached. There are folders on the server everyone accesses as well as printers shared on individual computers. I set up two accounts...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.