X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: Yes, hits=5.5 required=5.0 tests=BAYES_40,BOTNET,SPF_NEUTRAL X-Spam-Check-By: sourceware.org Message-id: <002301ca000f$242cb6a0$8e0410ac@wirelessworld.airvananet.com> From: "Pierre A. Humblet" To: "Rajiv Garg" , References: <24395640 DOT post AT talk DOT nabble DOT com> Subject: Re: Intermittent Cron Errors Date: Wed, 08 Jul 2009 17:00:34 -0400 MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com ----- 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 ". 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 #include #include #include 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