appending LK to the shadow file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting appending LK to the shadow file
# 1  
Old 10-01-2008
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 below i have written up a menu and a function module but have no idea what to do from there to append LK to a particular user by writing the LK to the shadow file

Code:
#!/bin/bash
MENUSTRING1="==================================="
MENUSTRING2="---------------------------------"

function DisplayMenu()
{
 
 echo "$MENUSTRING1"
 echo "$MENUSTRING2"
 echo "Select an option from the menu"
 echo "$MENUSTRING2"
 echo "$MENUSTRING1"

 echo "[1] Lock an account by prepending LK to the password field in etc/shadow"
 echo "[2] Force a change of password by mod password expiry and grace period"
 echo         "so that the user has at least 1 week to login and change the password"
 echo "[3] Set an account so that it expires at a particular date"
 echo "[4] set a new password(using passwd)For this purpose, a modified version"
 echo      "of passwd that takes two extra arguments will be supplied"
 echo      "since the real passwd requires superuser privileges to run."
 echo "[5] Change the home directory path for a user"
 echo "[6] Change the default shell for a user"
 echo "[7] EXIT" 
 
}

function menuInput()
{

  read USERCHOICE
 echo "Executing your selected option"
 
 if [ $USERCHOICE -eq 1 ]; then
 echo "you have chosen to lock the account using the shadow file"
 lockAccount

 else
 echo Unkown Option $USERHCOICE
 fi

}

function lockAccount()
{
  echo "Successfully locked the account"
}

DisplayMenu
menuInput

# 2  
Old 10-01-2008
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. 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

3. 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

4. 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

5. 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

6. 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

7. Solaris

Shadow file definition

Hi Could someone Pls let me know how to define a shadow file, i.e what do each of the following stand for: root:SedGsw.WadR:13200:7:30:5:30:: What would the column headings be? Thnaks (1 Reply)
Discussion started by: narik007
1 Replies

8. Solaris

Passwords in /etc/shadow file

I want to import my passwd/shadow files from Solaris 6 to Solaris 10. I found that the encryption method for passwords has changed. Is there a command or script to convert the Solaris 6 passwords to Solaris 10? I have searched the net and just can't seem to find the answer. For Example: The... (6 Replies)
Discussion started by: westsiderick
6 Replies

9. Programming

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... (4 Replies)
Discussion started by: Sabari Nath S
4 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