[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: groupadd -R problem



On Tue, Oct 1, 2013 at 8:09 PM, Wim Bertels <wim.bertels@khleuven.be> wrote:
>
>>
>>         How do u add a group with --root or -R option?
>>         the error message doesn't seem to make sense.
>>
>>         This is an example:
>>
>>         ROOT@debian:/tmp# mkdir /blabla
>>         ROOT@debian:/tmp# groupadd -R /blabla testChroot
>>         groupadd: cannot lock /etc/group; try again later.
>>         ROOT@debian:/tmp# groupadd testChroot
>>
>>         without the -R option just works..

What exactly are you trying to do?

>>
>> You have misunderstood the groupadd comand. It is used to add new
>> group to the system and NOT to change the group ownersheep of a
>> directory as in your example. Read the man page for groupadd and chown
>> to see the difference.
>
> Maybe my example was not clear:
> the objective was to add a group, not to change the group ownership.
>
> cf
> -R, --root CHROOT_DIR
>            Apply changes in the CHROOT_DIR directory and use the
>            configuration files from the CHROOT_DIR directory.

What group were you trying to add, and to which version of /etc/group?

> So i'm guessing this only applies when u have chrooted "OS's" within
> your OS?

I'm guessing you're getting closer.

When I want to add a group to the system, I usually specify the name
of the new group on the command line:

addgroup -gid 2045  newgroup

adds the group name "newgroup" to the /etc/group file and the shadow
file, performing some checking as it goes. You can do this by hand
with the vigr command, as well, but you have to remember to type
things in the same way in both the "visible" and the shadow group
files. And there are other checks directly editing doesn't do. (You
can be even more direct and use vi, but vigr does do some of the
checking for you, and allows you to specify the shadow group file
without knowing the name of the file.)

In the example you show above, I'm guessing that the reason the system
says you aren't able to lock the group file is that there is no group
file (in the file specified as the chroot directory for the jail) to
lock. Since your example shows you make the directory and then
immediately try to add a group, it is apparent that a lot of the
initialization that would have to be done first has not been done.

man -k chroot

and then man the manual entries listed to read more about setting up a
jail. Check the references at the bottom of each man page. It may take
an hour or two to figure out the difference between what you were
trying to do and what the command was trying to do for you.

On the other hand, it may be enough to know that the -R option is not
necessary if you are not setting up a chroot jail.

--
Joel Rees

Be careful where you see conspiracy.
Look first in your own heart.


Reply to: