Reputation: 48
I have a problem that I have not been able to solve for several weeks. I created a registration page that uses the php language to put the user, password and other elements in the database. I use freeipa for kerberos authentication/LDAP/NTP.
I just want to create the user in freeipa after the registration in the database
For that i launch a bash script with the exec function of php when a user signs up after all the verifications and the capcha .... This bash script is very simple and chmod is 700 with the owner root:
#!/bin/bash
username="$1"
kinit -k -t /tmp/keytab manageuser@MYDOMAIN
ipa user-add $username --first $username --last $username --homedir /app/$username --shell /usr/sbin/nologin
My keytab:
-rw------- 1 root root 160 mai 20 17:19 keytab
I launch this bash script in php
$cmd = "sudo ../script $username";
exec($cmd, $output);
print_r($output);
Of course the apache user is in the sudoer file for only this script
I created a user "manageuser" in FREEIPA with the manage user's role, in order to create the users.
This script works when I run in a terminal, and the user is created in freeipa but when the exec function of php launches the script it does not create the user.
I have the impression that kinit does not work with php exec function, why ?
Thank you in advance for your help
Upvotes: 1
Views: 278