Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
pw keeps setting /etc/group to 0600
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ryan Stone  
View profile  
 More options Nov 17 2012, 10:24 am
Newsgroups: mpc.lists.freebsd.current, muc.lists.freebsd.current
From: Ryan Stone <ryst...@gmail.com>
Date: Sat, 17 Nov 2012 10:24:16 -0500
Local: Sat, Nov 17 2012 10:24 am
Subject: pw keeps setting /etc/group to 0600
/etc/group is supposed to be world-reable, right?  Tools like groups or pw
groupshow certainly seem to think so:

[rstone@rstone-server ~]groups
1001 920
[rstone@rstone-server ~]ls -l /etc/group
-rw-------  1 root  0  482 Nov 14 21:02 /etc/group
[rstone@rstone-server ~]sudo chmod a+r /etc/group
Password:
[rstone@rstone-server ~]groups
rstone vboxusers
[rstone@rstone-server ~]sudo pw groupadd foo
[rstone@rstone-server ~]ls -l /etc/group
-rw-------  1 root  0  494 Nov 17 10:19 /etc/group
[rstone@rstone-server ~]

I'm not sure what caused the regression.  I've been seeing the problem
since I first installed -CURRENT on the machine a couple of weeks ago.
_______________________________________________
freebsd-curr...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ryan Stone  
View profile  
 More options Nov 17 2012, 11:20 am
Newsgroups: mpc.lists.freebsd.current, muc.lists.freebsd.current
From: Ryan Stone <ryst...@gmail.com>
Date: Sat, 17 Nov 2012 11:20:21 -0500
Local: Sat, Nov 17 2012 11:20 am
Subject: Re: pw keeps setting /etc/group to 0600
Wow.  So apparently things are even more broken than I though.  Let's play,
"What group am I in?"

root@group-testing:/usr/home/rstone # cd /tmp
root@group-testing:/tmp # pw groupadd testing
root@group-testing:/tmp # mkdir testdir
root@group-testing:/tmp # chown root:testing testdir/
root@group-testing:/tmp # chmod g+rwx testdir/
root@group-testing:/tmp # pw usermod
root@group-testing:/tmp # pw groupmod testing -m rstone
root@group-testing:/tmp # id rstone
uid=1001(rstone) gid=1001(rstone) groups=1001(rstone),0(wheel),1002(testing)
root@group-testing:/tmp # exit
$ id
uid=1001(rstone) gid=1001 groups=1001,0
$ id rstone
uid=1001(rstone) gid=1001 groups=1001
$ touch /tmp/testdir/testfile
touch: /tmp/testdir/testfile: Permission denied
$ ls -ld /tmp/testdir/
drwxrwxr-x  2 root  1002  512 Nov 17 11:07 /tmp/testdir/

My original complaint that /etc/group gets permissions of 0600 is a result
of a bug in libutil, which bapt@ ported pw to use in r242349.  The new
group manipulation API using mktemp to create a temporary file, writes the
new group database to the temp file and then renames the temp file to
/etc/group.  The problem here is that mktemp creates a file with a mode of
600, and libutil never chmods it.  That should be pretty trivial to fix.  I
have no idea what's happening in my example above, though.  Baptiste, I
have to ask: how much testing did r242349 receive before it was committed?
_______________________________________________
freebsd-curr...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mateusz Guzik  
View profile  
 More options Nov 17 2012, 12:28 pm
Newsgroups: mpc.lists.freebsd.current, muc.lists.freebsd.current
From: Mateusz Guzik <mjgu...@gmail.com>
Date: Sat, 17 Nov 2012 18:28:08 +0100
Local: Sat, Nov 17 2012 12:28 pm
Subject: Re: pw keeps setting /etc/group to 0600

This is not a bug and I think it always was this way. The process you used
to su/sudo/whatever to root was not in testing group and didn't
magically enter it after you added rstone user to that group. You have
to log in again or do stuff like exec su - rstone.

--
Mateusz Guzik <mjguzik gmail.com>
_______________________________________________
freebsd-curr...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mateusz Guzik  
View profile  
 More options Nov 19 2012, 5:29 pm
Newsgroups: mpc.lists.freebsd.current, muc.lists.freebsd.current
From: Mateusz Guzik <mjgu...@gmail.com>
Date: Mon, 19 Nov 2012 23:28:43 +0100
Local: Mon, Nov 19 2012 5:28 pm
Subject: Re: pw keeps setting /etc/group to 0600

On Sat, Nov 17, 2012 at 11:20:21AM -0500, Ryan Stone wrote:
> My original complaint that /etc/group gets permissions of 0600 is a result
> of a bug in libutil, which bapt@ ported pw to use in r242349.  The new
> group manipulation API using mktemp to create a temporary file, writes the
> new group database to the temp file and then renames the temp file to
> /etc/group.  The problem here is that mktemp creates a file with a mode of
> 600, and libutil never chmods it.  That should be pretty trivial to fix.

My additional 0,03$:

I took closer look to this and I think that problems are much broader
than this. I don't know if similar problems were present before.

First, pw should not fail if other instance is running, it should wait
instead (think of parallel batch scripts adding some users/groups).

Second, current code has a race:
lockfd = open(group_file, O_RDONLY, 0);
if (lockfd < 0 || fcntl(lockfd, F_SETFD, 1) == -1)
        err(1, "%s", group_file);
if (flock(lockfd, LOCK_EX|LOCK_NB) == -1) {
[..]
gr_copy(pfd, tfd, gr, old_gr); /* copy from groupfile to tempfile */
[..]
rename(tempfile,groupfile);

Now let's consider threads A and B:

A: open()
A: lock();
A: gr_copy
B: open()

Now B has file descriptor to /etc/group that is about to be removed.

A: rename()
A: unlock()
B: lock()

Now B has a lock on unlinked file.

B: gr_copy()
B: rename()

... and stores new content losing modifications done by A

Third, I don't like current api.
gr_lock and gr_tmp have no arguments (that matter anyway)
gr_copy operates on two descriptors given as arguments
gr_mkdb takes nothing and is expected to do The Right Thing

I think descriptos should be hidden. Also I think that passing around
struct gr_something (sorry, never had talent for names) that would
contain all necessary data would be nice.

--
Mateusz Guzik <mjguzik gmail.com>
_______________________________________________
freebsd-curr...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Baptiste Daroussin  
View profile  
 More options Nov 19 2012, 5:39 pm
Newsgroups: mpc.lists.freebsd.current, muc.lists.freebsd.current
From: Baptiste Daroussin <b...@freebsd.org>
Date: Mon, 19 Nov 2012 23:37:45 +0100
Local: Mon, Nov 19 2012 5:37 pm
Subject: Re: pw keeps setting /etc/group to 0600

gr_mkdb should chmod 0644 after renaming if rename worked.

I should work on this soon.

The API has been design to match the exact same api of pw_utils, I don't like it
either but at least this is consistent.

regards,
Bapt

  application_pgp-signature_part
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Baptiste Daroussin  
View profile  
 More options Nov 20 2012, 2:25 am
Newsgroups: mpc.lists.freebsd.current, muc.lists.freebsd.current
From: Baptiste Daroussin <b...@freebsd.org>
Date: Tue, 20 Nov 2012 08:24:59 +0100
Local: Tues, Nov 20 2012 2:24 am
Subject: Re: pw keeps setting /etc/group to 0600

Should be fixed now,

regards,
Bapt

  application_pgp-signature_part
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jaakko Heinonen  
View profile  
 More options Nov 21 2012, 10:46 am
Newsgroups: mpc.lists.freebsd.current, muc.lists.freebsd.current
From: Jaakko Heinonen <j...@FreeBSD.org>
Date: Wed, 21 Nov 2012 17:45:43 +0200
Local: Wed, Nov 21 2012 10:45 am
Subject: Re: pw keeps setting /etc/group to 0600
On 2012-11-19, Mateusz Guzik wrote:

> First, pw should not fail if other instance is running, it should wait
> instead (think of parallel batch scripts adding some users/groups).

> Second, current code has a race:
> lockfd = open(group_file, O_RDONLY, 0);
> if (lockfd < 0 || fcntl(lockfd, F_SETFD, 1) == -1)
>    err(1, "%s", group_file);
> if (flock(lockfd, LOCK_EX|LOCK_NB) == -1) {
> [..]
> gr_copy(pfd, tfd, gr, old_gr); /* copy from groupfile to tempfile */
> [..]
> rename(tempfile,groupfile);

Hmm, could using the O_EXLOCK flag for open() instead of flock() help here?

--
Jaakko
_______________________________________________
freebsd-curr...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mateusz Guzik  
View profile  
 More options Nov 21 2012, 11:27 am
Newsgroups: mpc.lists.freebsd.current, muc.lists.freebsd.current
From: Mateusz Guzik <mjgu...@gmail.com>
Date: Wed, 21 Nov 2012 17:27:18 +0100
Local: Wed, Nov 21 2012 11:27 am
Subject: Re: pw keeps setting /etc/group to 0600

Yes, this would fix the race.

But the problem of pw exiting due to other process holding the lock
remains. And I think that fixing it will require holding a lock over
whole time pw is running so that we have stable snapshot of user base at
least in regard of local files.

One could create one lock, say /etc/.pw.lock, that would be used to
synchronize any changes to /etc/master.passwd, /etc/group and whatnot.

And then there is this API issue (but maybe this is just me
nitpicking).

--
Mateusz Guzik <mjguzik gmail.com>
_______________________________________________
freebsd-curr...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
matt  
View profile  
 More options Nov 30 2012, 12:42 pm
Newsgroups: mpc.lists.freebsd.current, muc.lists.freebsd.current
From: matt <sendtom...@gmail.com>
Date: Fri, 30 Nov 2012 09:42:57 -0800
Local: Fri, Nov 30 2012 12:42 pm
Subject: Re: pw keeps setting /etc/group to 0600
On 11/17/12 07:24, Ryan Stone wrote:

Interesting, I noticed my pw segfaulted twice on 'pw groupdel' twice out
of three groups deleted.

Not sure if related. I'm at r243502.

Matt
_______________________________________________
freebsd-curr...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »