This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Intermittent Cron Errors


----- Original Message ----- 
From: "Rajiv Garg"
To: cygwin
Sent: Wednesday, July 08, 2009 1:14 PM


|
| Hi,
|
| We are seeing intermittent cron errors on some of our servers.  We run about
| a couple of hundred jobs on these servers, and about 5% of them fail with
| the error "can't switch user context").  We enabled verbose logging, and in
| /var/log/cron.log see messages that say "cannot set uid for <user>".  What
| is odd is that the same job, with the same user will run successfully 95% of
| the time.  So it doesn't seem to be a permission issue or configuration
| issue.
|
| Can anyone shed some light on where we should next for this?  Output from
| cronbug is attached.
|
| Thanks,
| Rajiv
|
|
| http://www.nabble.com/file/p24395640/cronbug.txt cronbug.txt
| -- 
********************

Rajiv,


Looks like both the daemon and the job are running underder the same account (orderworker).
Is that your understanding? If so the setuid operation should be a noop and thus should never 
fail.

I don't know what happens. You are the first one to report this problem. Perhaps the PDC cannot 
be contacted for some reason, from time to time. Do you see that at your site?
At any rate it's a cygwin issue, not a cron issue.

Turning on verbose cron logging won't help, the failure is already visible in the regular log 
(included in cronbug.txt). Debugging this would require running under strace, but that's 
impractical given the huge amount of useless data that will be generated.

If you have the time, please compile and run the C program below, if possible on the machine 
where cron runs and under user "orderworker".
It tries to duplicate what cron does. If the error shows up we can try to strace that program.

Else perhaps the most practical way out for you is to create a special version of cron where the 
call to setuid is bypassed when the job account is identical to the daemon account.
That would be a one liner in do_command.c . If you can't do that yourself I can provide you an 
updated cron in the coming days.

******
#include <sys/types.h>
#include <grp.h>
#include <stdio.h>
#include <unistd.h>

main()
{
   int uid, gid, i;
   char * name = getlogin();
   uid = getuid();
   gid = getgid();
   printf("name %s uid %d gid %d\n", name, uid, gid);

   for (i = 0; ; i++) {
        if (initgroups(name, gid))
           printf("Initgroups failure at i = %d \n", i);

        if (setuid(uid)) {
           printf("Setuid failure at i = %d \n", i);
           exit(1);
        }
        if (!(i & 0XFF)) printf("%d\n", i);
   }
}


Pierre


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]