LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 07-08-2002, 02:07 PM   #1
akohlsmith
Member
 
Registered: Apr 2002
Distribution: Slackware
Posts: 114

Rep: Reputation: 15
Question adding a user from a package?


I'm no newbie to slackware but I've run across a problem I am not sure how to solve.

I created an openssh3.4p1 package. No problem.

In order to use privilege separation I need to add a user to the system.

My question is: How do I add a user to the system from within the package? I can't use useradd since /etc/passwd|shadow are not guaranteed to be the "real" passwd and shadow files (think of a new install, / is the RAM disk).

Similarly, I can't just append a line on to etc/passwd|shadow (note: no leading /) because I can't guarantee that the uid isn't already used. Well, I can, but that's a lot of extra work to generate the next free uid to use.

Any ideas?
 
Old 07-08-2002, 03:00 PM   #2
pickledbeans
Member
 
Registered: Jun 2002
Location: Bailey, CO
Distribution: Slackware
Posts: 483

Rep: Reputation: 31
I'll give you an "E" for effort but an "F" for not checking
the slackware ftp sites:

http://www.slackware.com/getslack
Here is one:
ftp://ftp.slackware-brasil.com.br/sl...ches/packages/

Download :
openssh-3.4p1-i386-1.tgz
File: openssh-3.4p1-i386-1.txt

As root:
# upgradepkg openssh-3.4p1-i386-1.tgz

# killall -HUP sshd

# exit

BYW, There is a boat load of pathes for 8.0

Last edited by pickledbeans; 07-08-2002 at 03:02 PM.
 
Old 07-08-2002, 03:11 PM   #3
akohlsmith
Member
 
Registered: Apr 2002
Distribution: Slackware
Posts: 114

Original Poster
Rep: Reputation: 15
Thumbs down Nope I don't want slackware's package

I compile specific options in (paths, etc.) so the stock one from ftp does me no good.

I will, however take a look and see what they did (or if they just turned off Privilege Separation)...

[update, 5 min later]

They cheat. <sigh>

# If the sshd user/group don't exist, add them:
if grep "^sshd:x:" etc/passwd 1> /dev/null 2> /dev/null ; then
true
else
echo "sshd:x:33:33:sshd:/:" >> /etc/passwd
fi
if grep "^sshd::" etc/group 1> /dev/null 2> /dev/null ; then
true
else
echo "sshd::33:sshd" >> etc/group
fi
if grep "^sshd:" etc/shadow 1> /dev/null 2> /dev/null ; then
true
else
echo "sshd:*:9797:0:::::" >> etc/shadow
fi

***

At any rate the question is a general question, not specific to openssh; in *any* package I create, how would I add users to the system without resorting to tricks like this? (say postgresql, or a backup package, or anything really)


Last edited by akohlsmith; 07-08-2002 at 03:14 PM.
 
Old 07-08-2002, 03:13 PM   #4
pickledbeans
Member
 
Registered: Jun 2002
Location: Bailey, CO
Distribution: Slackware
Posts: 483

Rep: Reputation: 31
To answer your other guestion? You use the same command
to create users and groups as used to create any user and
groups accounts.
 
Old 07-08-2002, 04:00 PM   #5
akohlsmith
Member
 
Registered: Apr 2002
Distribution: Slackware
Posts: 114

Original Poster
Rep: Reputation: 15
Angry Have you actually been a slack user since '95?

The reason I ask is because you aren't reading my message, and slack users are often the ones which have read quite a bit. :-)

useradd *will*not*work* in all instances since / may not be the actual root of the final filesystem!

e.g. pop in the slack cd, boot from it with the intention of installing a new system. run useradd; it won't add it to the real system, just the boot system.

That is because useradd expects the /etc/passwd and /etc/shadow to be off of the root filesystem. That is *not* the case with ramdisk-root systems such as a CD-based install, since the eventual / is actually /mnt or /var/mount or wherever the installer happens to mount it.

I read the useradd manpage but it doesn't appear to have any option to specific which passwd/shadow file to use. If it did, I'd just tell it to use etc/passwd instead of /etc/passwd.

I've been a slack user since '96 or so... It's just been recently that I've been creating my own packages which is why I'd never run across this before. a.out to elf conversion? no problem. libc5 to glibc conversion? no problem. Intelligently adding a user to a system from inside a package? <grumble>
 
Old 07-08-2002, 04:34 PM   #6
pickledbeans
Member
 
Registered: Jun 2002
Location: Bailey, CO
Distribution: Slackware
Posts: 483

Rep: Reputation: 31
Why don't you cross-post the a couple of other list, maybe one like dev. I think your off base here. The locations of the
passwd file (which you seem to be hung up on), is a Unix stardard ...... since ATT wrote it way back when.....

BTW, Have you taken apart a Slack package and study how
it works?

Last edited by pickledbeans; 07-08-2002 at 04:36 PM.
 
Old 07-08-2002, 06:05 PM   #7
akohlsmith
Member
 
Registered: Apr 2002
Distribution: Slackware
Posts: 114

Original Poster
Rep: Reputation: 15
Unhappy

I posted here specifically because it is a slackware-specific issue.

I know that /etc/passwd and shadow are the correct locations. I don't think you're understanding the question though :-(

useradd adds a user to a running system. It does this without flaws.

Packages can be installed into running systems or into temporary "set up" systems. These temporary systems (usually) run from ram disk, in which case /etc/passwd|shadow aren't the "real" /etc/passwd|shadow, they're the passwd and shadow files for the setup system image.

It's trivial to use useradd to add a user to a running system. That is not the issue.

The issue is that since packages can be installed from a setup system or a running system, I need a method for adding to the passwd/shadow files in both cases.

I've taken a few packages apart but it appears that they don't worry about this; they use a specific uid and gid and simply cat that on to the end of the existing passwd|shadow file. That works fine, but if that uid or gid is already used you'll get funny results.

The uid or gid may already be used on a running system. There are general conventions which can be followed but no real way to be sure, whcih is what useradd does perfectly.

<sigh> oh well; I guess I can use shell scripting to scan the passwd file for a uid that doesn't exist. I was hoping there was a better way to do it. :-)

Thanks for your time in this; I really do appreciate your effort. And I love your signature.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Error adding package (Fedora) RWBlue01 Linux - Newbie 5 03-18-2005 12:52 PM
Adding a package so rpm can find it dangerousdave Linux - Newbie 2 02-22-2005 11:39 AM
Adding second user jnhannah Linux - Security 1 06-27-2004 02:50 PM
adding the RH9 development package seth_m Linux - Software 2 10-02-2003 06:50 PM
Redhat, FTP Install and Adding Package? drumltd Red Hat 5 09-28-2003 05:52 AM


All times are GMT -5. The time now is 07:10 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration