I was trying to use a magic script in Samba 4.2.4 and it failed if the path had spaces in it. It looks like when it eventually runs sh it loses the everything after the first space. The logs show: [2016/02/03 12:39:35.710809, 5, pid=58471] ../source3/smbd/close.c:54(check_magic) checking magic for Tim Test/dropoff/CLM_perm ./Tim: not found [2016/02/03 12:39:35.713845, 3, pid=58471] ../source3/smbd/close.c:96(check_magic) Invoking magic command ./Tim Test/dropoff/CLM_perm gave 127 The patch below fixed it by putting the path the the magic script in quotes. It seemed to be the cleanest way to do it. *** source3/smbd/close.c.orig Wed Feb 3 15:35:58 2016 --- source3/smbd/close.c Mon Feb 8 07:41:39 2016 *************** *** 81,87 **** } /* Ensure we don't depend on user's PATH. */ ! p = talloc_asprintf(ctx, "./%s", fname); if (!p) { status = NT_STATUS_NO_MEMORY; goto out; --- 81,87 ---- } /* Ensure we don't depend on user's PATH. */ ! p = talloc_asprintf(ctx, "\"./%s\"", fname); if (!p) { status = NT_STATUS_NO_MEMORY; goto out;