Re: delete user in group script

2010-12-28 Thread Jean-Francois Simon
On Tuesday 14 December 2010 13:16:59 Markus Hennecke wrote: > On Tue, 14 Dec 2010, OpenBSD Geek wrote: > > I made as I could, since it works, where is the probleme...? ;-) > > Tomas already pointed out where this will blow up for sure. > > Hint: Take a look at mktemp(1) and install(1) to weed out

Re: delete user in group script

2010-12-15 Thread Alexander Hall
This must be the most horrible thread ever in terms of scripting and sh/ksh (ab)use I've ever seen. Please, folks, don't consider using anything posted in this thread, or god will start killing kittens. On 12/14/10 12:31, OpenBSD Geek wrote: > Hi, > > After posted many requests on how to remove

Re: delete user in group script

2010-12-15 Thread Jan Stary
On Dec 14 19:00:53, Leonardo Rodrigues wrote: > Ok! Here goes my contribution to this thread! > > # $1=group > # $2=user > > cd /etc > cat ./group \ > | sed '/'$1'/ s/'$2'//' \ Hm, that's a nice one too: for every line in /etc/group that contains '$1', remove the first occurence of '$2'.

Re: delete user in group script

2010-12-14 Thread Adriaan
On Tue, Dec 14, 2010 at 10:00 PM, Leonardo Rodrigues wrote: > Ok! Here goes my contribution to this thread! > > # $1=group > # $2=user > > cd /etc > cat ./group \ >| sed '/'$1'/ s/'$2'//' \ >| sed '/'$1'/ s/,,/,/' \ >| sed '/'$1'/ s/,$//' \ >| sed '/'$1'/ s/:,/:/' >

Re: delete user in group script

2010-12-14 Thread Ted Unangst
On Tue, Dec 14, 2010 at 4:00 PM, Leonardo Rodrigues wrote: > mv /etc/group.new /etc/group > chown root.wheel /etc/group > chmod 644 /etc/group A) root:wheel is better. B) it's a bad idea to fix the permissions of a file after installing it.

Re: delete user in group script

2010-12-14 Thread Leonardo Rodrigues
Ok! Here goes my contribution to this thread! # $1=group # $2=user cd /etc cat ./group \ | sed '/'$1'/ s/'$2'//' \ | sed '/'$1'/ s/,,/,/' \ | sed '/'$1'/ s/,$//' \ | sed '/'$1'/ s/:,/:/' > group.new mv /etc/group.new /etc/group chown root.wheel /etc/group chmod 64

Re: delete user in group script

2010-12-14 Thread Jan Stary
On Dec 14 15:31:40, OpenBSD Geek wrote: > Hi, > > After posted many requests on how to remove user from a group, i choosed > to build my own script. > And it works very fine. > > if [ $1 ] & [ $2 ]; then > cp /etc/group /tmp > cat /tmp/group | grep ^$2 > /tmp/onlygroup > cat /tmp/group | grep -v

Re: delete user in group script

2010-12-14 Thread Markus Hennecke
On Tue, 14 Dec 2010, OpenBSD Geek wrote: I made as I could, since it works, where is the probleme...? ;-) Tomas already pointed out where this will blow up for sure. Hint: Take a look at mktemp(1) and install(1) to weed out the worst issues. Kind regards, Markus

Re: delete user in group script

2010-12-14 Thread OpenBSD Geek
I made as I could, since it works, where is the probleme...? ;-) > You really deserve the Useless Use of Cat Award. > And the race condition award, and the nuke the wrong file award, and... > > Kind regards, >Markus

Re: delete user in group script

2010-12-14 Thread Tomas Bodzar
On Tue, Dec 14, 2010 at 12:31 PM, OpenBSD Geek wrote: > Hi, > > After posted many requests on how to remove user from a group, i choosed > to build my own script. > And it works very fine. > > if [ $1 ] & [ $2 ]; then > cp /etc/group /tmp > cat /tmp/group | grep ^$2 > /tmp/onlygroup > cat /tmp/gro

Re: delete user in group script

2010-12-14 Thread Markus Hennecke
On Tue, 14 Dec 2010, OpenBSD Geek wrote: Hi, After posted many requests on how to remove user from a group, i choosed to build my own script. And it works very fine. if [ $1 ] & [ $2 ]; then cp /etc/group /tmp cat /tmp/group | grep ^$2 > /tmp/onlygroup cat /tmp/group | grep -v ^$2 > /tmp/nogro

Re: delete user in group script

2010-12-14 Thread Otto Moerbeek
On Tue, Dec 14, 2010 at 03:31:40PM +0400, OpenBSD Geek wrote: > Hi, > > After posted many requests on how to remove user from a group, i choosed > to build my own script. > And it works very fine. > > if [ $1 ] & [ $2 ]; then > cp /etc/group /tmp > cat /tmp/group | grep ^$2 > /tmp/onlygroup > ca