LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-08-2010, 01:56 AM   #1
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
LFS /tools/bin/groups not displaying supplementary groups


Always good to become the newbie again

So i am at the stage of about to install the basic system and am using a derivation of the package management provided by Matthias S. Benkmann.
To this end I am using his useradd and groupadd scripts to update the files:
/etc/passwd
/etc/group

My issue is that when I run the commands(created as part of temporary system when installing coreutils):
Code:
/tools/bin/su linux
#then as user
/tools/bin/groups

linux
(here linux is the name of the user)

This only returns the user being in the group named after user but not the additional group of 'install'

Also, prior to logging in as user, if I use this command as root:
Code:
/tools/bin/groups linux 

linux install
This then returns that the user is in the correct groups.

Lines from relevant files look like:
Code:
#/etc/passwd
linux:x:10000:10000::/usr/src/build:/bin/bash

#/etc/group
install:x:1001:linux
linux:x:10000
Any help would be greatly appreciated as to which stupid error I have made

Cheers grail
 
Old 06-09-2010, 03:30 AM   #2
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
Any pointer to Matthias S. Benkmann's scripts? What is the script code? What are they supposed to do, what did you expect them to do, and what is it actually doing?
 
Old 06-09-2010, 03:32 AM   #3
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,325

Rep: Reputation: 2330Reputation: 2330Reputation: 2330Reputation: 2330Reputation: 2330Reputation: 2330Reputation: 2330Reputation: 2330Reputation: 2330Reputation: 2330Reputation: 2330
You're in the LFS book, chapter 5?
They say FBBG Follow Book - Book Good.
What page are you on? Or is this an external trick, in which case you're on your own.
I don't think you need users to start chapter 6. In chapter 6, you're in a chroot to /tools, so you don't see /tools
 
Old 06-09-2010, 04:25 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Original Poster
Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
@Agrouf - Yes I used "Matthias S. Benkmann's scripts" as a guideline.

useradd:
Code:
if [ $# -ne 11 -o z$1 != z-d -o z$3 != z-g -o z$5 != z-G -o z$7 != z-s -o z$9 != z-u ]; then
echo 1>&2 USAGE: useradd -d home -g maingroup -G addgroup -s shell -u uid login 
exit 1
fi

#test if user already exists
grep "^${11}:.*" /etc/passwd 
if [ $? -eq 0 ]; then
  echo 1>&2 $0: User does already exist
  exit 1
fi       

g=`grep ^${4}:.\* /etc/group | cut -d : -f 3 -`
if [ z${g} = z ]; then
  echo 1>&2 $0: Group ${4} does not exist!
  exit 1
fi

grep ^${6}:.\* /etc/group >/dev/null || \
{
  echo 1>&2 $0: Group ${6} does not exist!
  exit 1
}


cp /etc/passwd /tmp/passwd123456
echo "${11}:x:${10}:$g::$2:/bin/bash" \
| sort -t : -k3,3n -m /tmp/passwd123456 - > /etc/passwd


cp /etc/group /tmp/group123456
sed  -e 's/^\('"${6}"':[^:]*:[0-9]*:..*\)$/\1,'"${11}"'/' \
     -e 's/^\('"${6}"':[^:]*:[0-9]*\):$/\1:'"${11}"'/' \
     						/tmp/group123456 >/etc/group
groupadd:
Code:
if [ $# -ne 3 -o z$1 != z-g ]; then
echo 1>&2 USAGE: groupadd -g gid groupname
exit 1
fi

#test if group already exists
grep "^${3}:.*" /etc/group 
if [ $? -eq 0 ]; then
  echo 1>&2 $0: Group does already exist
  exit 1
fi       

cp /etc/group /tmp/group123456
echo ${3}:x:${2}: | sort -t : -k3,3n -m /tmp/group123456 - > /etc/group
Both of these update the two corresponding files correctly.

@business_kid - I am on page 6.7 Linux-2.6.34 API Headers. Your following statement is not quite correct:
Quote:
I don't think you need users to start chapter 6. In chapter 6, you're in a chroot to /tools, so you don't see /tools
When you chroot you are in the top level of the mounted directory which does contain tools directory
eg.
Code:
export LFS=/mnt/lfs
mkdir -pv $LFS
mount -v -t ext3 /dev/<xxx> $LFS

mkdir -v $LFS/tools
So from this you can see that tools dir is under /mnt/lfs

Then the chroot is:
Code:
chroot "$LFS" /tools/bin/env -i \
    HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
    /tools/bin/bash --login +h
So here we have chrooted into /mnt/lfs

Upshot is, I am still stuck with root being able to get the right groups with the command but not a user who is being su'ed into.
 
Old 06-09-2010, 04:38 AM   #5
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
Quote:
Originally Posted by grail View Post
Upshot is, I am still stuck with root being able to get the right groups with the command but not a user who is being su'ed into.
Sorry, I read your posts 3 times and I still don't get what your problem is. Which command are you talking about in that sentence?
I understood you want linux in groups linux and install. It looks like /etc/group contains the right groups but /mnt/lfs/etc/group does not contain it?
Could you please post the commands you type one by one, the result you get and the result you expect?
something like that:


I type this:

$ ls
file1 file2 file3

And I expect this:

$ ls
file4

Last edited by Agrouf; 06-09-2010 at 04:41 AM.
 
Old 06-09-2010, 04:51 AM   #6
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
Sorry, I've reread a 4th time and I think I get it now.
Basically, you do this:
Code:
# /tools/bin/groups linux
linux install
# /tools/bin/su linux
$ /tools/bin/groups
linux
And you expect that:
Code:
# /tools/bin/groups linux
linux install
# /tools/bin/su linux
$ /tools/bin/groups
linux install
Correct?

Is /tools/etc/groups readable by everybody? It should be 644
 
Old 06-09-2010, 04:54 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Original Poster
Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
No probs

As root in chroot environment:
Code:
root# groups linux

linux : linux install

root# su linux

linux$ groups

linux
 
Old 06-09-2010, 04:55 AM   #8
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Original Poster
Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Yes that's what I expect and yes it is readable.
 
Old 06-09-2010, 09:57 PM   #9
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Original Poster
Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Ok ... so I have done some more testing and thought I would also explain why I thought this was necessary:

1. Extra testing - interestingly, even though when the user runs groups command on its own it does not display the extra group(s), if I submit the following:
Code:
linux$groups linux
I get:
Quote:
linux : linux install
Which is the output I expected???

2. Reason for query - i was installing another program, man-pages, and this is done as the man-pages user. As per the LFS instructions the install is very simply:
Code:
make install
This now runs the following for loop as per the Makefile contained in the package:
Code:
for i in man?; do \
    install -d -m 755 $(DESTDIR)$(MANDIR)/"$$i" || exit $$?; \
    install -m 644 "$$i"/* $(DESTDIR)$(MANDIR)/"$$i" || exit $$?; \
done;
Where DESTDIR is blank and MANDIR=/usr/share/man.

Now as part of LFS you create these directories already and also:
Quote:
/usr/share/man/man[1-8]
On my system there is an extra step where I change the group to be install and the permissions to be 775 so group can make changes.

On executing the first line in the "for" example above the script hits an error that permission is denied on changing the permissions, hence why I looked
to see what groups had been assigned to the user, in this case man-pages (linux was just shorter to type before), and on typing in the "groups" command
was told that man-pages (and later i found linux also) was not considered in the install group

I have since made a change to the Makefile to test if folder already exists and only then use the install -d -m line.

My question now I guess two fold:

1. Still why the erroneous output when submitting just the "groups" command as normal user?

2. Was this lack of acknowledgement of the install group the reason why the man-pages user was unable to execute the following example:
Code:
install -d -m 755 /usr/share/man/man1
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] [c] set supplementary groups of process Meson Programming 2 03-21-2010 05:22 PM
Micro$oft AD Groups to Debian Lenny Groups.- Mindblower Linux - Desktop 0 04-22-2009 09:28 AM
Map Windows NT Groups to UNIX Groups - why? kenji1903 Linux - Networking 4 10-16-2007 11:52 AM
winbind: wbinfo -g only lists global groups from PDC and not local groups saradiya Linux - Networking 0 12-01-2003 02:58 AM
Supplementary groups ? and group? what is the difference? funnyusa Linux - Newbie 3 06-29-2003 03:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration