Apache Server configuration support - cron adduser

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > August 2007 > cron adduser





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author cron adduser
Séverin Richard

2007-08-23, 1:31 pm

Hi,

creating a .php containing
<? exec( "useradd myuser" ) ?>

and called by cron as root does not create a user.


What can i change to make it work??

thx for idears.
patpro ~ Patrick Proniewski

2007-08-23, 1:31 pm

In article <46cd9980$0$416$426a74cc@news.free.fr>,
Séverin Richard <severin.richard@free.fr> wrote:

> Hi,
>
> creating a .php containing
> <? exec( "useradd myuser" ) ?>
>
> and called by cron as root does not create a user.
>
>
> What can i change to make it work??


wouaaaa.
That's looks like the worst idea ever to me.
I see 3 problems here :

you should not allow php to run exec.
you can't call a command requiring root privileges from apache
if you want to create users automatically, you must keep everything out
of reach of remote users.

I don't know what brainstorming yielded to your cron/php thing, but be
sure it's a very bad idea.

patpro

--
http://www.patpro.net/
Séverin Richard

2007-08-23, 1:31 pm

FIRST:
root privilege do not allow users to call the php script:
http://themachine/thesecretpass/myphpEXEC.php
returns "NOT ALLOWED gid unsificient..etc"...

SECOND:
the phpscript makes a database query and implements users that had
allready suscribe the site, and are waiting for confimation.

No other user may be added here.
all Strings concerning users are escaped with all no alphanumeric
characteres.
$secureSTR = ereg( "[^0-9a-zA-Z]","", rowsquerySrt );


THIRD:
I have to create user dynamicaly...




Who can help??





patpro ~ Patrick Proniewski wrote:[vbcol=seagreen]
> In article <46cd9980$0$416$426a74cc@news.free.fr>,
> Séverin Richard <severin.richard@free.fr> wrote:
>
>
>
>
> wouaaaa.
> That's looks like the worst idea ever to me.
> I see 3 problems here :
>
> you should not allow php to run exec.
> you can't call a command requiring root privileges from apache
> if you want to create users automatically, you must keep everything out
> of reach of remote users.
>
> I don't know what brainstorming yielded to your cron/php thing, but be
> sure it's a very bad idea.
>
> patpro
>

phantom

2007-08-23, 1:31 pm

"Séverin Richard" <severin.richard@free.fr> wrote in message
news:46cd9980$0$416$426a74cc@news.free.fr...
> Hi,
>
> creating a .php containing
> <? exec( "useradd myuser" ) ?>
>
> and called by cron as root does not create a user.


If it didn't work, then surely you'll have some errors - cron output
generally gets emailed somewhere (and this output will probably tell you why
it didn't work)

> What can i change to make it work??


you'll probably find that cron doesn't have the same path as your logged in
user and you'll need to do:
<?php exec("/usr/sbin/useradd myuser"); ?>


Séverin Richard

2007-08-23, 1:31 pm

Tanks Phantom for ur answer.

In fact i make a log file for output.

fwrite( $log , exec( "whoami" ))

works and returns root.

BUT !!!

useradd needs effectively to be called by real path !!!!!!!!!!!!!!!!!

thxthxthx...




phantom wrote:
> "Séverin Richard" <severin.richard@free.fr> wrote in message
> news:46cd9980$0$416$426a74cc@news.free.fr...
>
>
>
> If it didn't work, then surely you'll have some errors - cron output
> generally gets emailed somewhere (and this output will probably tell you why
> it didn't work)
>
>
>
>
> you'll probably find that cron doesn't have the same path as your logged in
> user and you'll need to do:
> <?php exec("/usr/sbin/useradd myuser"); ?>
>
>

MonTassaR

2007-08-24, 1:28 pm

On Aug 23, 4:28 pm, S=E9verin Richard <severin.rich...@free.fr> wrote:
> Hi,
>
> creating a .php containing
> <? exec( "useradd myuser" ) ?>
>
> and called by cron as root does not create a user.
>
> What can i change to make it work??
>
> thx for idears.


Instead of creating system users dynamically that way, I would :

1- replace your php file with an other one that simply writes the
username I want to create in a temporary text file thata remotely
called php script can access ..
2- add a cron that periodically runs a shell script as root that,
checks wheter the temporary file contain some users to add, add users
if ever there are users to add and empty the file/comment the line
containing the user that's bee already added ..

This seems to me much more clean than using php exec() ...

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com