Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Programmatically Adding E-Mail Accounts

by matija (Priest)
on Sep 15, 2004 at 05:45 UTC ( #391089=note: print w/ replies, xml ) Need Help??


in reply to Programmatically Adding E-Mail Accounts

And I know that I shouldn't be doing this on a shared account, but I'm just playing around.
Buddy, if you "shouldn't be doing that" then "just playing around" is no excuse.

Unless you have root on the machine, adduser won't work. And passwd doesn't accept a password on the command line (it would be a huge security breach if it did), you'll have to use Expect;

As for the rest of your questions, they depend on the details of how the server was set up, and this is not the place to discuss them. You want a unix discussion forum. Go back two routers and turn left.


Comment on Re: Programmatically Adding E-Mail Accounts
Download Code
Re^2: Programmatically Adding E-Mail Accounts
by tachyon (Chancellor) on Sep 15, 2004 at 06:45 UTC

    And passwd doesn't accept a password on the command line (it would be a huge security breach if it did), you'll have to use Expect;

    That is not actually correct. For example you can (as root) do:

    sub add_shell_passwd { my ( $user, $shellpwd ) = @_; open PWD, "|$PASSWD_BIN --stdin $user" or die "Can't open pipe to +$PASSWD_BIN $!\n"; print PWD $shellpwd, "\n"; close PWD; }

    On the other hand adding a shell password adds a full shell account for the user. For the benefit of the OP there are many ways to skin this cat. If you want to make real user accounts you either want to make /dev/null the users default shell (so they can't login) or use say cram-md5 so they can have a pop3 pwd but no shell password. This is typically NOT what you want to do. Try Googling for 'creating virtual pop3 accounts linux'

    cheers

    tachyon

      That is not actually correct.
      Actually, it IS.

      The passwd manpage on Linux (Debian) and Solaris do not list the --stdin switch. Quite possibly you are running some system that supports it, but that DOES NOT make what I said incorrect.

      The question did not define which operating system the machine he is using actually runs, but it's far more likely that it doesn't support --stdin that that it does.

        but it's far more likely that it doesn't support --stdin that that it does.

        Well given that it is valid for passwd(1) on RH, and RH is the most popular Linux, and RH has 50% market share according to netcraft, which is 3x Debian I would simply have to disagree with that premise. Linux is also about 2:1 Unix and 50% of Unix is Solaris so RH is 2:1 Solaris AOTBE.

        [root@devel3 bayes_cache]# uname -a Linux devel3.blah.org 2.4.18-3smp #1 SMP Thu Apr 18 07:27:31 EDT 2002 +i686 unknown [root@devel3 bayes_cache]# man passwd PASSWD(1) User utilities PASSWD(1) NAME passwd - update a user's authentication tokens(s) SYNOPSIS passwd [-k] [-l] [-u [-f]] [-d] [-S] [username] DESCRIPTION Passwd is used to update a user's authentication token(s). [snip] --stdin This option is used to indicate that passwd should read +the new password from standard input, which can be a pipe.

        cheers

        tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://391089]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2014-07-10 08:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (203 votes), past polls