passwd

PHP - shell_execute -change user password

Hi, I need to be able to change the users' password through a web page (in a controlled environment). So, for that, I'm using this code: <?php $output = shell_exec("sudo -u dummy passwd testUser testUserPassword"); $output2 = shell_exec("dummyPassword"); echo $output; echo $output2; echo "done"; ?> My problem is that this script is n...

php - proc_open (or other function that works)

I need to do some command lines through a browser. What I need to do in a command-line would be: $login <login name> <password> $passwd <old password> <new password> <retype new password> So, how can I do this using the proc_open function? Or should I use another function to do this? Thanks ...

Problem with an expect script

Hi, I'm trying to create a script to update a password in a non-interactive way. It's working on my laptop but fails on my server. Both are running the same configuration, using Etch. This is the script: #!/usr/bin/expect -f # Change user passwd set timeout 30 strace 4 set password [lindex $argv 1] set old_password [lindex $argv 2] s...

What API do I call to set a user's password on linux?

I know about passwd(1) and crypt(3). What I'm looking for is a C API to call which will set the user's password in the passwd/shadow files, without having to programatically walk the files and overwrite the entry for the user in question. Application runs as root. Does such an API exist? EDIT: Guess I should specify, the password is...

Useradd using crypt password generation

Hello, I am working on what I thought was a very simple script to dynamically create an FTP user using 'useradd' There are several parts of this process I am unfamiliar with, and an entire day's research has not gotten me too far. Here is what I have thus far: Notes: 1) HOME_DIR and GROUP are obviously erroneous, I have used these as pl...

Unix programming. Not sure how to use the passwd struct

I've done some research and I'm still struggling with the passwd structure. http://www.opengroup.org/onlinepubs/000095399/basedefs/pwd.h.html I need to obtain the user ID however I dont think I'm using understanding it at all. int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **); This method call returns a point t...

SVN: Global and project-specific passwd files for single repository

I would like to configure my local SVN server to support both a global passwd file and a project specific passwd file. I have a global passwd file set up that is currently used to administer all accounts. The only problem is, sometimes we want to an outside developer to a single project. With our current setup, we have to grant them acc...

How to automatically add user account *and* password with a Bash script

I need to have the ability to create user accounts on my Linux ( Fedora 10 ) and automatically assign a password via a bash script ( or otherwise, if need be ). It's easy to create the user via Bash eg: [whoever@server ]# /usr/sbin/useradd newuser But is it possible to assign a password in Bash, something functionally similar to thi...

Protecting /etc/passwd and /etc/shadow from concurrent access

How do I protect /etc/passwd and /etc/shadow from concurrent access? I don't see any locking mechanism in pwd.h. I see the manual for pwd_mkdb mentions obtaining a lock, but is it just locking the file for exclusive access? Is there a convention for locking these files if I were to write a utility to modify them directly, or through t...

Script to Copy User according to UID

I'm looking for a way to copy all non-system users from one PC to another. I can get the group and passwd files copied over using this awk -F":" ' $3 > 499 ' etc/passwd >> /etc/passwd awk -F":" ' $3 > 499 ' etc/group >> /etc/group But, how would I go about getting the shadow file copied over since it does not store the UID? Assume tha...

Change Unix password from command line over Python/Fabric

I would like a way to update my password on a remote Ubuntu 10.4 box with fabric. I would expect my fabfile.py would look something like this: def update_password(old_pw, new_pw): # Connects over ssh with a public key authentication run("some_passwd_cmd --old %s --new %s" % (old_pw, new_pd)) Unfortunately the only command I k...

passwd: Authentication failure on redhat

Hi, I have an application (APP1) which can only be executed by a user with root privileges but not by root. Hence I have created another user root1 : adduser -u 0 -o -g 0 -G 0,1,2,3,4,6,10 -M root1 And then when I am trying to assign a password to this user I get an authentication failure. [root]# passwd root1 Changing password for ...

How do I generate an encrypted password string, as it is in /etc/shadow?

Hi, I'm trying to mimic the creation of password strings as they appear in /etc/shadow. This is what I've got so far, but the encrypted passwords don't match, when I use the same password and the same salt. 5000 rounds is standard for crypt, so I used that as well, but I don't see where exacly I made a mistake: I'm doing this in Perl,...