delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/04/28/16:27:54

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <427147E2.C58BE533@dessent.net>
Date: Thu, 28 Apr 2005 13:30:26 -0700
From: Brian Dessent <brian AT dessent DOT net>
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: pointer to getting cron to run w/user creds?
References: <427143FF DOT 70108 AT tlinx DOT org>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com

Linda W wrote:

> I remember this discussion on the cygwin list, but wasn't able to find a
> reference to in the FAQ.
> 
> I have a nightly cron job that I'd like to back up my home windows dir to a
> samba machine, but when it runs, I'm sorta sure that it doesn't know what
> cygwin-uid to run with.
> 
> Could someone point where getting cron to work with my credentials has been
> covered?  I did google for "cron UID credentials site:cygwin.com", but
> it came
> up empty -- shouldn't that have found the dicussion in the cygwin list
> archives?

cron switches to the user who owns the crontab, you don't have to
configure anything for that to happen, that's just how cron works.

However, your question should probably be, "Why can't I access a network
share from a cronjob?"  The answer to that has to do with how
impersonation works on windows.  The summary is that accessing network
resources as a specific user requires that user's actual password in the
process token.  When a service like cron switches to another user, that
is not present, so it's impossible to access a network share.  It works
when you actually log in as that user as your password is stored in the
token when you login.

The solution is one of:

- Make network shares read/writable (as needed) for Guest/anonymous
access.
- Run 'net use' in the cronjob and explicitly specify a password to
mount the share to a drive letter.
- Install the cron service to run as the actual user.

If you opt for the latter, cron will only be able to run cronjobs for
that user, you lose the functionality of cron being a general purpose
daemon.  And you will have to specify that user's password to cygrunsrv
when you install the service, which is how the process token gets the
password.

Brian

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019