reg adding Users into at.allow and removing from at.allow


 
Thread Tools Search this Thread
Top Forums Programming reg adding Users into at.allow and removing from at.allow
# 1  
Old 04-10-2007
reg adding Users into at.allow and removing from at.allow

Hi ,

Thanks for your time .

I am working on a application , which adds unix user through useradd and deletes user through userdel . both are admin commands .

My requirement is i have to add a user into at.allow whenver a unix user is added through my application and the user should be deleted from at.allow whenever a user is deleted from my application .
is there any way i can do this through a C program or a shell script .

for at.allow addition i can write a small script having a line
echo "Bill" >> /var/adm/at.allow .


but if i want to delete the same bill in at.allow , how can i delete from at.allow .
is there any specific way to do this through a command or a program.

IN simple words i have to update the file with new user and delete the existing user from at.allow.

many thanks for your time .

Cheers
Narendra
# 2  
Old 04-10-2007
You can use a small script for deletion as well. Use grep/sed/awk/ex to remove the unwanted userid, output to a temp file, move the temp file back over the at.allow file.

Something like:
Code:
grep -v "Bill" /var/adm/at.allow > /tmp/at.allow.$$
mv /tmp/at.allow.$$ /var/adm/at.allow

grep/sed will require that you create a temp file, ex will allow the actual at.allow file to be edited.
Code:
ex /var/adm/at.allow <<EOF
/Bill
d
wq
EOF

Will remove the id Bill from the /var/adm/at.allow file.
# 3  
Old 04-10-2007
Many Thanks Blowtorch for your answer .

But here i cannot solve concurrency issues , multiple users accessing the same file.
two people using at.allow may cause incosistent at.allow file .

so i have to locak it before i update it .

any information reg the same a C program to lock , remove and unlock the at.allow so that we can avoid concurrency issues .

many thanks
Narendra
# 4  
Old 04-10-2007
Are you using a C program to do this or a shell script? You can use lockf in C. It allows record level locking of files, but if you do that, I am not sure that you can use another script to update the file.
# 5  
Old 04-11-2007
Quote:
Originally Posted by naren_chella
so i have to locak it before i update it .

any information reg the same a C program to lock , remove and unlock the at.allow so that we can avoid concurrency issues .
Look at https://www.unix.com/showthread.php?t...highlight=lock
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding users from a txt fille

hello i'm making a bash script for adding users from a txt fille i have a basic script that adds users and their password . when you type the users by hand , now i want to upgrade my script with a txt file of users and their password , but i don't know how to start . my txt file looks... (10 Replies)
Discussion started by: Roggy
10 Replies

2. Shell Programming and Scripting

Simple script for adding users

Hi guys, I've a simple linux script (made by my friend), which adds users to the system from userlist file. it also creates user home dir and copies certain files to the directory. To be honest, am a newbie in scripting so am unable to fully understand how the script is working. unfortunately,... (30 Replies)
Discussion started by: vish6251
30 Replies

3. AIX

adding users via smit

I apologize if this is a simple/stupid question. When I add users in smit as root, many(most) of the fields are automatically popluated with some basic default values. Some other admins here have access to create users via sudo, however when they create users (sudo smit users), the user gets... (3 Replies)
Discussion started by: mshilling
3 Replies

4. Solaris

Removing users from groups

How do I remove a user from a group? I'm using the usermod command but its not working. I have a user "abc" who is a member of the groups root and other. I'm trying to remove him from the group "other" (using CLI) which is his secondary group but it's not working. How do I do this? Is there any... (11 Replies)
Discussion started by: the_red_dove
11 Replies

5. UNIX for Dummies Questions & Answers

Adding users question

Hello there, I want to add new users to my system, so, being logged in as root I do useradd -m user_name, and the new user is added to the system. The problem is that it has more privileges than I expected. If I do su user_name then I am allowed to do cat /etc/passwd , so it is... (4 Replies)
Discussion started by: help.goes.here
4 Replies

6. UNIX for Dummies Questions & Answers

User Name and Password List/adding and removing users.

Hello everyone and let me start off by thanking anyone who can help with this. I work for a company that uses Unix as one of their servers. I'm not at all familar with Unix beyond logging after I restart the server:rolleyes: I'm looking for some command that will bring me up a list of current... (3 Replies)
Discussion started by: disgracedsaint
3 Replies

7. Shell Programming and Scripting

Removing users from sudoers - help needed

I'm trying to create a script to remove users from sudoers on multiple servers. I'm able to do this with a one-line script using sed, but only if it's on one server. Example: sed '/someuser/d' /host/local/etc/sudoers Also, I think the problem with this one-line script is that I would have to... (4 Replies)
Discussion started by: em23
4 Replies

8. UNIX for Dummies Questions & Answers

Adding users to /etc/group

I'm using SAM to add users on an HP and they're adding fine. But in /etc/group it only lists the group names. It's not adding the users in there. Is there a way to have them put in there without going into SAM and modifying the group and adding them? I guess what I want to happen is when I add... (1 Reply)
Discussion started by: golfhakker
1 Replies

9. Shell Programming and Scripting

Adding a backslash to users' input

Hi, I need to convert user-input from '(this)' to '\(this\)' before passing it to egrep. I've tried using TR, SED and NAWK to add the backslash, but the most I ever get is a backslash without a '(' or ')'. Any ideas? Thanks! (13 Replies)
Discussion started by: netguy
13 Replies

10. Shell Programming and Scripting

Adding users

Anyone have a simple shell script that will prompt and accept screen input for each field that is required in the /etc/passwd file? (3 Replies)
Discussion started by: Relykk
3 Replies
Login or Register to Ask a Question