crontab(1) confused by su(1)?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

crontab(1) confused by su(1)?

Jan Stary
crontab(1) says

     -u user   Specifies the name of the user whose crontab(5) is to be
               edited. If this option is not given, crontab examines ``your''
               crontab(5); i.e., the crontab of the person executing the
               command. Note that su(1) can confuse crontab and that if you
               are running inside of su(1) you should always use the -u option
               for safety's sake.

Is this actually true?
For me, it has always done the expected thing,
i.e., run as the user su(1)'d to.
Could someone please provide an example
where su(1) confuses crontab(1)?

        Jan

Reply | Threaded
Open this post in threaded view
|

Re: crontab(1) confused by su(1)?

Jan Stary
On Jul 16 13:23:01, [hidden email] wrote:

> crontab(1) says
>
>      -u user   Specifies the name of the user whose crontab(5) is to be
>       edited. If this option is not given, crontab examines ``your''
>       crontab(5); i.e., the crontab of the person executing the
>       command. Note that su(1) can confuse crontab and that if you
>       are running inside of su(1) you should always use the -u option
>       for safety's sake.
>
> Is this actually true?
> For me, it has always done the expected thing,
> i.e., run as the user su(1)'d to.

Realy,

> Could someone please provide an example
> where su(1) confuses crontab(1)?
>
> Jan

Reply | Threaded
Open this post in threaded view
|

Re: crontab(1) confused by su(1)?

Luca Ferrari
On Wed, Jul 24, 2013 at 8:32 AM, Jan Stary <[hidden email]> wrote:

>> Could someone please provide an example
>> where su(1) confuses crontab(1)?

If I get it right the problem is not running crontab, rather modifying
the crontrab files.
In such case the following could be an example: I ask su(1) to become
another user without modifying the environment, therefore I'm another
user running in the same environment of the former (than there's a
privilege problem, of course). Crontab searches for the current uid
while I would like to see the old one.


% id
                                        ~
uid=1001(luca) gid=1001(luca) groups=1001(luca),0(wheel)
% su -m pgsql
                                        ~
% echo $USER
                                       ~
luca
% crontab -l
                                       ~
crontab: no crontab for pgsql


However I could have totally missed the point...but it's an interesting one.

Luca

Reply | Threaded
Open this post in threaded view
|

Re: crontab(1) confused by su(1)?

Jan Stary
On Jul 26 08:42:52, [hidden email] wrote:

> On Wed, Jul 24, 2013 at 8:32 AM, Jan Stary <[hidden email]> wrote:
>
> >> Could someone please provide an example
> >> where su(1) confuses crontab(1)?
>
> If I get it right the problem is not running crontab, rather modifying
> the crontrab files.
> In such case the following could be an example: I ask su(1) to become
> another user without modifying the environment, therefore I'm another
> user running in the same environment of the former (than there's a
> privilege problem, of course). Crontab searches for the current uid
> while I would like to see the old one.
>
>
> % id
>                                         ~
> uid=1001(luca) gid=1001(luca) groups=1001(luca),0(wheel)
> % su -m pgsql

%id

> % echo $USER
>                                        ~
> luca
> % crontab -l
>                                        ~
> crontab: no crontab for pgsql

You have su'd to pgsql, and crontab -l
is showing you the (nonexistent) crontab of pgsql.

That's intended. I was asking for an example
of su being "confused" by su.