diff -Nacr source.orig/include/proto.h source/include/proto.h *** source.orig/include/proto.h Mon May 17 18:27:59 1999 --- source/include/proto.h Tue May 18 13:43:51 1999 *************** *** 1104,1109 **** --- 1104,1110 ---- char *lp_hostsdeny(int ); char *lp_magicscript(int ); char *lp_magicoutput(int ); + char *lp_close_command(int ); char *lp_comment(int ); char *lp_force_user(int ); char *lp_force_group(int ); diff -Nacr source.orig/param/loadparm.c source/param/loadparm.c *** source.orig/param/loadparm.c Mon May 17 18:37:43 1999 --- source/param/loadparm.c Tue May 18 13:43:51 1999 *************** *** 280,285 **** --- 280,286 ---- char *szHostsdeny; char *szMagicScript; char *szMagicOutput; + char *szCloseCommand; char *szMangledMap; char *szVetoFiles; char *szHideFiles; *************** *** 375,380 **** --- 376,382 ---- NULL, /* szHostsdeny */ NULL, /* szMagicScript */ NULL, /* szMagicOutput */ + NULL, /* szCloseCommand */ NULL, /* szMangledMap */ NULL, /* szVetoFiles */ NULL, /* szHideFiles */ *************** *** 798,803 **** --- 800,806 ---- {"dont descend", P_STRING, P_LOCAL, &sDefault.szDontdescend, NULL, NULL, FLAG_SHARE}, {"magic script", P_STRING, P_LOCAL, &sDefault.szMagicScript, NULL, NULL, FLAG_SHARE}, {"magic output", P_STRING, P_LOCAL, &sDefault.szMagicOutput, NULL, NULL, FLAG_SHARE}, + {"close command", P_STRING, P_LOCAL, &sDefault.szCloseCommand, NULL, NULL, FLAG_SHARE}, {"delete readonly", P_BOOL, P_LOCAL, &sDefault.bDeleteReadonly, NULL, NULL, FLAG_SHARE|FLAG_GLOBAL}, {"dos filetimes", P_BOOL, P_LOCAL, &sDefault.bDosFiletimes, NULL, NULL, FLAG_SHARE|FLAG_GLOBAL}, {"dos filetime resolution",P_BOOL,P_LOCAL,&sDefault.bDosFiletimeResolution, NULL, NULL, FLAG_SHARE|FLAG_GLOBAL}, *************** *** 1286,1291 **** --- 1289,1295 ---- FN_LOCAL_STRING(lp_hostsdeny,szHostsdeny) FN_LOCAL_STRING(lp_magicscript,szMagicScript) FN_LOCAL_STRING(lp_magicoutput,szMagicOutput) + FN_LOCAL_STRING(lp_close_command,szCloseCommand) FN_LOCAL_STRING(lp_comment,comment) FN_LOCAL_STRING(lp_force_user,force_user) FN_LOCAL_STRING(lp_force_group,force_group) diff -Nacr source.orig/smbd/close.c source/smbd/close.c *** source.orig/smbd/close.c Fri May 14 20:06:39 1999 --- source/smbd/close.c Tue May 18 13:43:51 1999 *************** *** 63,68 **** --- 63,99 ---- } /**************************************************************************** + run the close command if it exists for the share + ****************************************************************************/ + static void check_close_command(files_struct *fsp, connection_struct *conn) + { + char *filename = fsp->fsp_name; + char *closecmd = lp_close_command(SNUM(conn)); + pstring syscmd; + int ret; + + if (!*closecmd) + return; + + DEBUG(5,("running close command for %s\n", fsp->fsp_name)); + + /* copy the command into the buffer for extensive meddling. */ + StrnCpy(syscmd, closecmd, sizeof(pstring) - 1); + + /* look for "%s" in the string. If there is no %s, we cannot tell the close command the filename. */ + if (!strstr(syscmd, "%s") && !strstr(syscmd, "%f")) { + DEBUG(2,("WARNING! No placeholder for the filename in the close command for service %s!\n", SERVICE(SNUM(conn)))); + } + + string_sub(syscmd, "%s", filename, 1023); + string_sub(syscmd, "%f", filename, 1023); + standard_sub(conn,syscmd); + + ret = smbrun(syscmd,NULL,False); + DEBUG(3,("Invoking close command %s gave %d\n",syscmd,ret)); + } + + /**************************************************************************** Common code to close a file or a directory. ****************************************************************************/ static void close_filestruct(files_struct *fsp) *************** *** 136,141 **** --- 167,177 ---- /* check for magic scripts */ if (normal_close) { check_magic(fsp,conn); + } + + /* check for close command */ + if (normal_close) { + check_close_command(fsp,conn); } /* diff -Nacr docs.orig/yodldocs/smb.conf.5.yo docs/yodldocs/smb.conf.5.yo *** docs.orig/yodldocs/smb.conf.5.yo Fri May 14 20:20:48 1999 --- docs/yodldocs/smb.conf.5.yo Tue May 18 13:43:50 1999 *************** *** 795,800 **** --- 795,802 ---- it() link(bf(casesignames))(casesignames) + it() link(bf(closecommand))(close command) + it() link(bf(comment))(comment) it() link(bf(copy))(copy) *************** *** 1419,1424 **** --- 1421,1441 ---- bf(Example:) tt( client code page = 936) + + label(closecommand) + dit(bf(close command (S))) + This parameter specifies a command to run when a file is closed. The command + takes the normal macro substitutions, in addition to %s and %f which will + include the path and name of the closed file, not including the path for the share. + + This can be used to make a drop off point where people can put files that need to + have some kind of automated process run on them. + + bf(Default:) + tt( No close command) + + bf(Example:) + tt( close command = echo "%u closed file %p/%s" >> /tmp/closedfiles.txt) label(codingsystem) dit(bf(codingsystem (G)))