New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple bash/ping processes on Windows 7 with Cygwin installed #216

Closed
jeffbeard opened this Issue Sep 9, 2011 · 5 comments

Comments

Projects
None yet
4 participants
@jeffbeard

jeffbeard commented Sep 9, 2011

I discovered an ever-growing list of bash.exe/ping.exe processes on my Windows 7 64bit system caused by the Prey "pull" script. The script naively assumes only two possible ping commands, based on OS, then sets command line arguments. Neither of the options work with the Cygwin ping program which is what was available in the path. Even worse, the options cause the Cygwin ping program not to return (clearly a Cygwin problem since "-c" and "-n" aren't valid options) which is why bash/ping processes were accumulating.

Any of these would be workable solutions:

  • Use the absolute path to Windows ping.exe
  • Include a ping.exe binary with Prey
  • Take into account Cygwin (it's probably the most popular UNIX-like env for Windows but there are others)

I found one discussion forum thread on the subject:

https://groups.google.com/d/topic/prey-security/EO-e4W4RH7I/discussion

And one recent issue that might be related:

https://github.com/tomas/prey/issues/204

@drewreece

This comment has been minimized.

Show comment
Hide comment
@drewreece

drewreece Sep 24, 2011

Contributor

Is 'which ping' any use? Does that return cygwin's ping?
What are the correct args for cygwin ping?

What does 'echo $PATH' look like for you & for the user that Prey runs under (sorry I don't know Windows too well).

I'm wondering if there is a reliable dynamic way to get pings path and avoid code forking for Windows. I suspect adding a ping.exe binary in the platform/windows/bin is the easiest solution? Is there a suitable one that uses the same args.

core/setup adds that folder to the $PATH so it should be found first & it won't affect Linux/ Mac.

Contributor

drewreece commented Sep 24, 2011

Is 'which ping' any use? Does that return cygwin's ping?
What are the correct args for cygwin ping?

What does 'echo $PATH' look like for you & for the user that Prey runs under (sorry I don't know Windows too well).

I'm wondering if there is a reliable dynamic way to get pings path and avoid code forking for Windows. I suspect adding a ping.exe binary in the platform/windows/bin is the easiest solution? Is there a suitable one that uses the same args.

core/setup adds that folder to the $PATH so it should be found first & it won't affect Linux/ Mac.

@jeffbeard

This comment has been minimized.

Show comment
Hide comment
@jeffbeard

jeffbeard Sep 25, 2011

"which ping" returns the cygwin ping but I expect that since I manually added the cygwin bin dir to my path. But it's not first and it doesn't look like the Prey setup added the Prey path to the Windows path. If it had added the MingW utils to my path I probably would have noticed other odd behavior in my local terminal sessions since it would have tried to run the MingW bash.exe rather than the Cygwin version.

Anyway, to accommodate a pre-existing *NIX environment on a Windows workstation, I might try assuming the location of ping.exe on Windows ($WINDIR/system32 or $SYSTEMROOT/system32 should work). Here's some untested code to give you an idea of what I'm describing:

    local net_check_target="www.google.com"
    if [ "$os" == "windows" ]; then
        local ping_cmd="$SYSTEMROOT/system32/ping -n"
    else
        local ping_cmd='ping -q -c'
    fi
    connected=`$ping_cmd 1 $net_check_target &> /dev/null && echo 1 || echo 0`

The other alternative is to include a ping.exe in the Prey environment however I did a quick look-around and I didn't find existing work building ping.exe with MingW so my assumption is that it might require a port to that environment.

jeffbeard commented Sep 25, 2011

"which ping" returns the cygwin ping but I expect that since I manually added the cygwin bin dir to my path. But it's not first and it doesn't look like the Prey setup added the Prey path to the Windows path. If it had added the MingW utils to my path I probably would have noticed other odd behavior in my local terminal sessions since it would have tried to run the MingW bash.exe rather than the Cygwin version.

Anyway, to accommodate a pre-existing *NIX environment on a Windows workstation, I might try assuming the location of ping.exe on Windows ($WINDIR/system32 or $SYSTEMROOT/system32 should work). Here's some untested code to give you an idea of what I'm describing:

    local net_check_target="www.google.com"
    if [ "$os" == "windows" ]; then
        local ping_cmd="$SYSTEMROOT/system32/ping -n"
    else
        local ping_cmd='ping -q -c'
    fi
    connected=`$ping_cmd 1 $net_check_target &> /dev/null && echo 1 || echo 0`

The other alternative is to include a ping.exe in the Prey environment however I did a quick look-around and I didn't find existing work building ping.exe with MingW so my assumption is that it might require a port to that environment.

@tomas

This comment has been minimized.

Show comment
Hide comment
@tomas

tomas Oct 5, 2011

Contributor

Hi Jeff,

Really happy you could spot this one out. I guess I never assumed that Cygwin would overlap Windows' execution paths.

I guess there's no problem of bundling a win32 native ping.exe binary in Prey (searching Google for "gnuwin32 ping" yields a bunch of results), but I guess you're solution is a cleaner one. Did you get to test it?

Contributor

tomas commented Oct 5, 2011

Hi Jeff,

Really happy you could spot this one out. I guess I never assumed that Cygwin would overlap Windows' execution paths.

I guess there's no problem of bundling a win32 native ping.exe binary in Prey (searching Google for "gnuwin32 ping" yields a bunch of results), but I guess you're solution is a cleaner one. Did you get to test it?

@jeffbeard

This comment has been minimized.

Show comment
Hide comment
@jeffbeard

jeffbeard Oct 6, 2011

Hi Tomas,

The change in my last comment has been running on my Windows 7 laptop since I posted the comment without any problems.

Cheers,

Jeff

EDIT: accidentally closed the issue. I'll leave that to the experts.

jeffbeard commented Oct 6, 2011

Hi Tomas,

The change in my last comment has been running on my Windows 7 laptop since I posted the comment without any problems.

Cheers,

Jeff

EDIT: accidentally closed the issue. I'll leave that to the experts.

@jeffbeard jeffbeard closed this Oct 6, 2011

@jeffbeard jeffbeard reopened this Oct 6, 2011

@fithsk

This comment has been minimized.

Show comment
Hide comment
@fithsk

fithsk Sep 17, 2012

I had a similar problem after installing Preyproject on Windows 7 64-bit. Two bash.exe tasks each consumed 25% cpu. I stopped the tasks, but when rebooting the computer, they start again. I had to remove Preproject for this reason.

fithsk commented Sep 17, 2012

I had a similar problem after installing Preyproject on Windows 7 64-bit. Two bash.exe tasks each consumed 25% cpu. I stopped the tasks, but when rebooting the computer, they start again. I had to remove Preproject for this reason.

@ghost ghost closed this Mar 15, 2013

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment