Bug 11722 - magic script fails when path contains spaces
Summary: magic script fails when path contains spaces
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-08 21:34 UTC by Tim L
Modified: 2016-02-08 21:34 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim L 2016-02-08 21:34:31 UTC
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;