Doubt on shadow file


 
Thread Tools Search this Thread
Top Forums Programming Doubt on shadow file
# 1  
Old 08-24-2005
Doubt on shadow file

Hi guys,

I have a doubt on shadow file ... In the Unix servers in which I am working, I cud see that the shadow file has only one permission set .. tht is read permission for only root user ... (-r--------) ....

So my basic doubt here is that how this file is being written then ... only through pwconv ??? Does even root user cant edit the file manually .....
If so, how pwconv which has the permissions (-r-xr-xr-x) do update the shadow file ???

Thanks & regards,

SNS
# 2  
Old 08-24-2005
As far as the kernel is concerned, with a local filesystem, root can read any file and write to any non-directory. Most editors will see the lack of a write permission for root and open /etc/shadow in read-only mode. So removing write permission for root prevents root from overwriting the accidentally with most editors and a very few other programs.

A good administrator should be very careful while operating as root and notice the lack of write permissions before modifying a file. So it also serves as a signal to administrators.

You can override the read-only status with most editors. In vi, the command is: ":w!", but it is a little risky.
# 3  
Old 08-24-2005
Oh ... tht's great ... so though root does not have write permission, does it mean that still he can open it in vi and overwrite it with w! .. rite ...

Does vi give this special overwrite permission for root alone ...

Because I created a file with write permission only to the owner .. and opened the file in vi as another user of same group and tried to save it with w! .. it said permission denied .. ;-( ... the same as expected .. then how come it allow the same for root alone .... does vi recognize root and grants him the privilege to overwrite ...

Really appreciate if anyone cud elaborate on this ..

Thanks in advance,

SNS
# 4  
Old 08-24-2005
Quote:
Originally Posted by Sabari Nath S
Does vi give this special overwrite permission for root alone ...

Because I created a file with write permission only to the owner .. and opened the file in vi as another user of same group and tried to save it with w! .. it said permission denied .. ;-( ... the same as expected .. then how come it allow the same for root alone .... does vi recognize root and grants him the privilege to overwrite ...

Really appreciate if anyone cud elaborate on this ..

Thanks in advance,

SNS
vi does not really write to the file. It makes a system call for this. It is at the syscall level that the permissions and other things are checked. It is the OS that permits a user to write to a file or otherwise.
# 5  
Old 08-25-2005
Sabari,
Quote:
then how come it allow the same for root alone .... does vi recognize root and grants him the privilege to overwrite ...
/etc/shadow is owned by root, thus root can modify at will permissions, be it read-only or no permission at all!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shadow file help

As a part of linux hardening In shadow file all Application accounts which are not locked must contain only an asterisk “*” in the Passwd field. But how would i do it by using command? Is there any way other than modifying shadow file to accomplish this task? (3 Replies)
Discussion started by: pinga123
3 Replies

2. UNIX for Advanced & Expert Users

Permissions for /etc/shadow file

Hi, What are the default file permissions for /etc/shadow file in Linux. and What is meant by open files in linux.Any body please help me.Thanks in advance. (2 Replies)
Discussion started by: Sharath Kumar
2 Replies

3. Solaris

delete shadow file

hi everybody i 'm beginner in solaris and by mistake i removed shadow file any one can help me to restore it from passwd file (4 Replies)
Discussion started by: maxim42
4 Replies

4. Shell Programming and Scripting

Shadow file

Hi, In shadow file smithj:Ep6mckrOLChF.:10063:0:99999:7::: 3rd Field 10063 indicates the number of days (since January 1, 1970) since the password was last changed. I want to get the result with script the date on which the password was last changed in YYYY-MM-DD format. can... (8 Replies)
Discussion started by: pinnacle
8 Replies

5. Shell Programming and Scripting

appending LK to the shadow file

Hey guys.. i need to be able to append 'LK' to a password field in the shadow file I cannot use commands such as usermod chsh i need to directly be able to manupilate the files through a menu driven interface. So in other words write to the shadow file How could i do this? so far... (1 Reply)
Discussion started by: musicmancanora
1 Replies

6. UNIX for Dummies Questions & Answers

Shadow File

I see conflicting definitions for the shadow file. For Solaris, what are the fields please? Thanks. (3 Replies)
Discussion started by: DavidS
3 Replies

7. UNIX for Advanced & Expert Users

/etc/shadow file....

Does anyone know what "!!" represents in the password field of the /etc/shadow file? :confused: (6 Replies)
Discussion started by: avcert1998
6 Replies

8. Solaris

*LK* in /etc/shadow file

my etc/shadow file showing *LK* for a particular user.. can u tell me under which circumstances a user is locked (5 Replies)
Discussion started by: vikashtulsiyan
5 Replies

9. UNIX for Advanced & Expert Users

shadow file

what does 'x' in the encrypted password field in /etc/shaodw file represent? (3 Replies)
Discussion started by: jbashir
3 Replies

10. UNIX for Dummies Questions & Answers

shadow file

Sirs, What is a shadow file,How it be usefull.For my project i have to keep the password in shawdow file also i am doing in php how can i do it. Thanks in advance, ArunKumar (3 Replies)
Discussion started by: arunkumar_mca
3 Replies
Login or Register to Ask a Question