Re: cron and copying files across drives: how?

2004-10-04 Thread Eric_Zeller


I thought I could bypass the system account not allowed to log into remote
drive by providing username and password to net use.
but that didn't work.
I tried going into Services Manager and changing the login information for
the cron service, but it wouldn't allow it to run (service ended
unexpectedly error)
I even added login as a service rights to myuser, but that didn't work.

I discovered ps -afW works for displaying Windows processess (not just
cygwin's) with useri'ds attached - cron shows up as either '0' or
'Everyone' depending on which box I'm using
(haven't researched why 2 cygwin installations behave differentlly - don't
consider it important in this case)

I had added cygwin.dll to the path earlier, but since this is a production
box, I'm not allowed to reboot it willy nilly - I had to wait until it's
scheduled reboot
sunday morning. Now I can run cygwin perl scripts from windows task
scheduler and that seems to work. (had to futz around with the paths a bit,
but it works)

Thank you everyone for your help - I will be using the crontab for the
monthly zip of log files since that is all local filesystems.






Brian Dessent [EMAIL PROTECTED] on 10/01/2004 07:51:50 PM

To:[EMAIL PROTECTED]
cc:[EMAIL PROTECTED]
Subject:Re: cron and copying files across drives: how?


[EMAIL PROTECTED] wrote:

That's where the problem comes in, as
these impersonated credentials are not sufficient to gain access
without having the user's password.  Otherwise a malicious program run
by a local user with administrator privs would have instant access to
anything on the network.

Your choices basically amount to: a) Run the cron daemon as your user
account, providing it with your password, or b) remove the access
restrictions on the network share.  Under a) there's no impersonation
necessary as the process is actually running as you and not as
SYSTEM-impersonating-you and your password is available in the token for
remote authentication.  To do this just use cygrunsrv to remove the
service and re-install it under a different user, or use the Services
MSC module to edit it directly.  As far as b) goes I think the only way
to make the share accessable to SYSTEM is to make it a public share,
i.e. accessable to Guest for read (and write if that's what you need.)
SYSTEM does not have any particular credentials since it's not a real
account, so I don't think you can assign it access without also making
the share public -- but I could be wrong.

To see what user account cron is running as, just look at the process
list.  ps -af will work, as would using something like Task Manager
with the User Name column enabled.

 Failing this method, how can I run cygwin perl scripts from a DOS shell?
(I
 can try and use the windows task scheduler, but currently I get an error
 that the cygwin1.dll is not loaded, I suppose I could just install perl
for
 windows directly, but that seems redundant)

You need cygwin1.dll in the path if you do this.  The usual way is to
add \cygwin\bin to your PATH system environment variable.  It's
prepended to your path for you when you run the bash prompt (but that
only affects that session), so it's only necessary to do this when you
want to run Cygwin programs directly, not launched from a bash shell.

 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/



Re: cron and copying files across drives: how?

2004-10-04 Thread Brian Dessent
[EMAIL PROTECTED] wrote:

 I tried going into Services Manager and changing the login information for
 the cron service, but it wouldn't allow it to run (service ended
 unexpectedly error)
 I even added login as a service rights to myuser, but that didn't work.

Files that were previously owned by SYSTEM would have had to be chown'd
to your user account, or sufficient rights granted.  The log file, the
crontabs themselves, config files, directories, etc. -- basically
anything that crond needs to be able to read or write and was previously
owned by SYSTEM.  Once you did that it probably would have run fine.

 I discovered ps -afW works for displaying Windows processess (not just
 cygwin's) with useri'ds attached - cron shows up as either '0' or
 'Everyone' depending on which box I'm using
 (haven't researched why 2 cygwin installations behave differentlly - don't
 consider it important in this case)

You probably need to run mkpasswd and mkgroup to generate or update the
/etc/passwd and /etc/group files.

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/



Re: cron and copying files across drives: how?

2004-10-04 Thread Corinna Vinschen
On Oct  4 12:04, [EMAIL PROTECTED] wrote:
 I thought I could bypass the system account not allowed to log into remote
 drive by providing username and password to net use.
 but that didn't work.

Note that you *must* use the domain\username syntax when calling 
net use in this scenario.  If you're not in a domain, then replace
domain by the name of the share server, e.g.:

  $ net use \\server\share mypasswd /user:server\myusername


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  mailto:[EMAIL PROTECTED]
Red Hat, Inc.

--
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/



Re: cron and copying files across drives: how?

2004-10-04 Thread Igor Pechtchanski
On Mon, 4 Oct 2004, Corinna Vinschen wrote:

 On Oct  4 12:04, [EMAIL PROTECTED] wrote:

Ahem, http://cygwin.com/acronyms/#PCYMTNQREAIYR? ;-)

  I thought I could bypass the system account not allowed to log into remote
  drive by providing username and password to net use.
  but that didn't work.

 Note that you *must* use the domain\username syntax when calling
 net use in this scenario.  If you're not in a domain, then replace
 domain by the name of the share server, e.g.:

   $ net use \\server\share mypasswd /user:server\myusername

 Corinna

Using proper quoting, of course, as in

$ net use '\\server\share' 'mypasswd' /user:'server\myusername'

HTH,
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_[EMAIL PROTECTED]
 |,4-  ) )-,_. ,\ (  `'-'   Igor Pechtchanski, Ph.D.
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing.  -- Dr. Jubal Harshaw

--
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/



Re: cron and copying files across drives: how?

2004-10-04 Thread Corinna Vinschen
On Oct  4 21:48, Corinna Vinschen wrote:
 On Oct  4 12:04, [EMAIL PROTECTED] wrote:
  I thought I could bypass the system account not allowed to log into remote
  drive by providing username and password to net use.
  but that didn't work.
 
 Note that you *must* use the domain\username syntax when calling 
 net use in this scenario.  If you're not in a domain, then replace
 domain by the name of the share server, e.g.:
 
   $ net use \\server\share mypasswd /user:server\myusername

Well, make that

$ net use server\\share mypasswd /user:server\\myusername

in a Cygwin shell.  Or quote appropriately.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  mailto:[EMAIL PROTECTED]
Red Hat, Inc.

--
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/



Re: cron and copying files across drives: how?

2004-10-01 Thread Eric_Zeller

I have not signed up to receive emails from this list, but I read it from
the archives, so I would appreciate being cc'd on any responses to this
thread.


I am also trying to use cron to grab log files everyday from a webserver
here at work (names have been changed to increase the difficulty of trying
to break in.

Cron runs as a different Windows user (SYSTEM), so things that work from
your normal logon may not work from there.

I put 'cygcheck -s' in a script and ran it from the command line and from a
cron entry and ran the 2 outputs through a diff program.
There were some non-critical differences in $PATH (mostly referencing
non-existent directories),
MAKE_MODE, PWD, and USER were not defined in the cron environment,
but everything else was the same, even the output of the id program

Output from C:\cygwin\bin\id.exe (nontsec)
UID: 1003(myuserid) GID: 513(None)
513(None)

Output from C:\cygwin\bin\id.exe (ntsec)
UID: 1003(myuserid) GID: 513(None)
0(root)   513(None)
544(Administrators)   545(Users)


Simple: the z drive isn't accesible to SYSTEM.  Either make it accessible
(by doing a net use before/when starting the service), or don't use
/cygdrive/z in your scripts.  FWIW, if the share is publicly accessible
you can use the following syntax instead:

* * * * * cp /cygdrive/c/Andrea/try.png //remote.machine/share/try.png

You may still need to do a net use, though.  Try testing it out in a
system-owned shell (Google for the recipe).
HTH,

I had already put a 'net use' statement in there (to make sure the drive is
mounted before I access it)
This works from the command line but fails in the cron environment

net use /USER:myuserid mywebserverlogs mypasswd

note: 'net use' (to return status) does succeed in the cron env.

So I have several questions:
How do I tell when I'm in a SYSTEM shell (other than the lack of the USER
env variable.
How can I mount a drive when I'm in a SYSTEM shell (do I lack permissions?
Is it sandboxed in some way?)
Failing this method, how can I run cygwin perl scripts from a DOS shell? (I
can try and use the windows task scheduler, but currently I get an error
that the cygwin1.dll is not loaded, I suppose I could just install perl for
windows directly, but that seems redundant)





--
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/



Re: cron and copying files across drives: how?

2004-10-01 Thread Brian Dessent
[EMAIL PROTECTED] wrote:

 Cron runs as a different Windows user (SYSTEM), so things that work from
 your normal logon may not work from there.
 
 I put 'cygcheck -s' in a script and ran it from the command line and from a
 cron entry and ran the 2 outputs through a diff program.
 There were some non-critical differences in $PATH (mostly referencing
 non-existent directories),
 MAKE_MODE, PWD, and USER were not defined in the cron environment,
 but everything else was the same, even the output of the id program

The cron daemon still does its best to switch from SYSTEM to the user
account whose crontab its running.  This impersonation means that id
will say that it's running as the user account for the crontab, just as
it would under unix.  The imperonsation works well for just about
everything except network shares.  That's where the problem comes in, as
these impersonated credentials are not sufficient to gain access
without having the user's password.  Otherwise a malicious program run
by a local user with administrator privs would have instant access to
anything on the network.

Your choices basically amount to: a) Run the cron daemon as your user
account, providing it with your password, or b) remove the access
restrictions on the network share.  Under a) there's no impersonation
necessary as the process is actually running as you and not as
SYSTEM-impersonating-you and your password is available in the token for
remote authentication.  To do this just use cygrunsrv to remove the
service and re-install it under a different user, or use the Services
MSC module to edit it directly.  As far as b) goes I think the only way
to make the share accessable to SYSTEM is to make it a public share,
i.e. accessable to Guest for read (and write if that's what you need.) 
SYSTEM does not have any particular credentials since it's not a real
account, so I don't think you can assign it access without also making
the share public -- but I could be wrong.

To see what user account cron is running as, just look at the process
list.  ps -af will work, as would using something like Task Manager
with the User Name column enabled.

 Failing this method, how can I run cygwin perl scripts from a DOS shell? (I
 can try and use the windows task scheduler, but currently I get an error
 that the cygwin1.dll is not loaded, I suppose I could just install perl for
 windows directly, but that seems redundant)

You need cygwin1.dll in the path if you do this.  The usual way is to
add \cygwin\bin to your PATH system environment variable.  It's
prepended to your path for you when you run the bash prompt (but that
only affects that session), so it's only necessary to do this when you
want to run Cygwin programs directly, not launched from a bash shell.

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/



Re: cron and copying files across drives: how?

2004-09-16 Thread Isaac Foraker
You need to net use the network drive before you can access it through 
cron.

IF
Andrea M wrote:
I am having a problem running a simple bash script with cron. The 
script executes and behaves as expected when run from the command 
line, but when run by cron, it fails to execute some commands.

I narrowed the problem down and found out that cron fails to copy 
files between drives; for example, the following does not work

* * * * * cp /cygdrive/c/Andrea/try.png /cygdrive/z/try.png
I should mention that the z drive is a network drive. And yes, a 
simple script containing that command does execute correctly from the 
prompt.

Thanks in advance

--
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/


Re: cron and copying files across drives: how?

2004-09-16 Thread Igor Pechtchanski
On Thu, 16 Sep 2004, Andrea M wrote:

 I am having a problem running a simple bash script with cron. The script
 executes and behaves as expected when run from the command line, but
 when run by cron, it fails to execute some commands.

Cron runs as a different Windows user (SYSTEM), so things that work from
your normal logon may not work from there.

 I narrowed the problem down and found out that cron fails to copy files
 between drives; for example, the following does not work

 * * * * * cp /cygdrive/c/Andrea/try.png /cygdrive/z/try.png

 I should mention that the z drive is a network drive.

Well, here's your problem.

 And yes, a simple script containing that command does execute correctly
 from the prompt.

 Thanks in advance

Simple: the z drive isn't accesible to SYSTEM.  Either make it accessible
(by doing a net use before/when starting the service), or don't use
/cygdrive/z in your scripts.  FWIW, if the share is publicly accessible
you can use the following syntax instead:

* * * * * cp /cygdrive/c/Andrea/try.png //remote.machine/share/try.png

You may still need to do a net use, though.  Try testing it out in a
system-owned shell (Google for the recipe).
HTH,
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_[EMAIL PROTECTED]
 |,4-  ) )-,_. ,\ (  `'-'   Igor Pechtchanski, Ph.D.
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing.  -- Dr. Jubal Harshaw

--
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/