patch for triggering SFTP process_write

valerio balbi valerio.balbi at gmail.com
Mon Jun 18 11:48:06 EST 2007


Hi Damien!

    I produced a little patch to the package ver. 4.6p1 for linux.
My company, for many bureaucratic reasons, was  interested in triggering 
each uploaded file to the server using sftp subsystem.
In Internet and in ML, all folks solve the problem using a script 
joining sftp command section to ssh command section, but unfortunately 
isn't my case.

The patch consist in a modification of sshd_config file. In this file I 
add two new directive for each user who want to trigger the write mechanism.
The new items in configuration file are essentially skipped by 
serverconf.c module: I'll try to be the less invasive I can...
In the other hand, SFTP-server re-read configuration file to catch the 
new items only if the config line contains pw->pw_name, i.e. the 
authenticated user of this sftp session.  Only in this case a new 
struct, called Trigger, is  filled with path and filename of the script 
to be triggered after the OKwrite event.
When calling the triggered script I check the F_OK and the X_OK status 
and, eventually, exit with error: so the client can notice the error too.
If all OK, I perform a fork+execv calling what indicated by struct Trigger.
With many user, I can perform different personalized procedures. 
(thinking at my case this is cool!)

Many stylistic enhancements can take place... but I'm a sysadm :P
I think this patch should be a usefull feature, in this case: nice to 
support the community!

Valerio Balbi     (aka pvb265)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openssh-4.6p1-pvb265p1.patch.bz2
Type: application/x-bzip
Size: 3245 bytes
Desc: not available
Url : http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20070618/efcc7943/attachment-0001.bin 


More information about the openssh-unix-dev mailing list