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: pointer to getting cron to run w/user creds?


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/


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