diff -Nacr samba-2.0.2.original/docs/yodldocs/smb.conf.5.yo samba-2.0.2/docs/yodldocs/smb.conf.5.yo *** samba-2.0.2.original/docs/yodldocs/smb.conf.5.yo Fri Feb 5 20:17:28 1999 --- samba-2.0.2/docs/yodldocs/smb.conf.5.yo Wed Mar 17 15:47:08 1999 *************** *** 785,790 **** --- 785,792 ---- it() link(bf(casesignames))(casesignames) + it() link(bf(closecommand))(close command) + it() link(bf(comment))(comment) it() link(bf(copy))(copy) *************** *** 1381,1386 **** --- 1383,1403 ---- 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))) diff -Nacr samba-2.0.2.original/source/include/proto.h samba-2.0.2/source/include/proto.h *** samba-2.0.2.original/source/include/proto.h Fri Feb 5 20:17:47 1999 --- samba-2.0.2/source/include/proto.h Wed Mar 17 15:05:53 1999 *************** *** 1100,1105 **** --- 1100,1106 ---- 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 samba-2.0.2.original/source/param/loadparm.c samba-2.0.2/source/param/loadparm.c *** samba-2.0.2.original/source/param/loadparm.c Mon Feb 15 13:12:01 1999 --- samba-2.0.2/source/param/loadparm.c Wed Mar 17 15:06:02 1999 *************** *** 278,283 **** --- 278,284 ---- char *szHostsdeny; char *szMagicScript; char *szMagicOutput; + char *szCloseCommand; char *szMangledMap; char *szVetoFiles; char *szHideFiles; *************** *** 374,379 **** --- 375,381 ---- NULL, /* szHostsdeny */ NULL, /* szMagicScript */ NULL, /* szMagicOutput */ + NULL, /* szCloseCommand */ NULL, /* szMangledMap */ NULL, /* szVetoFiles */ NULL, /* szHideFiles */ *************** *** 815,820 **** --- 817,823 ---- {"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}, *************** *** 1303,1308 **** --- 1306,1312 ---- 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 samba-2.0.2.original/source/smbd/close.c samba-2.0.2/source/smbd/close.c *** samba-2.0.2.original/source/smbd/close.c Mon Feb 15 12:59:37 1999 --- samba-2.0.2/source/smbd/close.c Wed Mar 17 15:37:59 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); + string_sub(syscmd, "%f", filename); + 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); } /*