[scponly] fixes for Cygwin
Oskar Liljeblad
oskar at osk.mine.nu
Thu Sep 15 05:28:45 EDT 2005
I've recently tried to set up scponly on Cygwin.
Two things needed to be fixed:
* Cygwin installs sftp-server in /usr/sbin, so perhaps
/usr/sbin should be added to the list of paths searched
for sftp-server in configure.ac.
* sftp-server won't run unless PATH contains either
/bin or /usr/bin. See attached patch.
Also, in scponly.c there's a call
retval=execve(av[0],av,NULL);
shouldn't the environment 'env' be passed here as well?
Regards,
Oskar Liljeblad (oskar at osk.mine.nu)
PS. Please CC me, I'm not on the list. DS.
-------------- next part --------------
--- xx/scponly-4.1/scponly.c 2005-04-13 07:31:27.000000000 +0200
+++ scponly-4.1/scponly.c 2005-09-15 11:15:39.673625000 +0200
@@ -386,7 +386,7 @@
char bad_winscp3str[] = "test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server exec sftp-server";
int retval;
int reqlen=strlen(request);
- char *env[2] = { NULL, NULL };
+ char *env[3] = { "PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin", NULL, NULL };
if (debuglevel)
syslog(LOG_DEBUG, "processing request: \"%s\"\n", request);
@@ -512,13 +512,13 @@
#ifdef UNISON_COMPAT
if (((strlen(homedir) + 6 ) > FILENAME_MAX) ||
- (-1 == asprintf( &env[0], "HOME=%s", homedir)))
+ (-1 == asprintf( &env[1], "HOME=%s", homedir)))
{
syslog(LOG_ERR, "could not set HOME environment variable(%s))", logstamp());
exit(EXIT_FAILURE);
}
if (debuglevel)
- syslog(LOG_DEBUG, "set HOME environment variable to %s (%s))", env[0], logstamp());
+ syslog(LOG_DEBUG, "set HOME environment variable to %s (%s))", env[1], logstamp());
#endif
syslog(LOG_INFO, "running: %s (%s)", flat_request, logstamp());
@@ -542,7 +542,7 @@
else
#endif
{
- retval=execve(av[0],av,NULL);
+ retval=execve(av[0],av,env);
}
syslog(LOG_ERR, "failed: %s with error %s(%u) (%s)", flat_request, strerror(errno), errno, logstamp());
free(flat_request);
More information about the scponly
mailing list