[pacman-dev] System hook dir contains a double slash

David Macek david.macek.0 at gmail.com
Wed Nov 25 22:19:38 UTC 2015


Hi all.

In `alpm_initialize`, there's

sprintf(hookdir, "%s%s", myhandle->root, SYSHOOKDIR);

where `SYSHOOKDIR` is by default `"/usr/share/libalpm/hooks/"` (defined by `-DSYSHOOKDIR=\"@datarootdir@/libalpm/hooks/\"` in `AM_CPPFLAGS`).

This means that the resulting `hookdir` is `"//usr/share/libalpm/hooks/"`, or `"/something/else//usr/share/libalpm/hooks/"` if `--root /something/else` is passed on command line.

If you need a reason for changing this (other than programmer's tidiness), know that this causes trouble in Cygwin/MSYS2 as paths starting with `//` have special meaning.

I can send a patch, but I'm not sure what's the best way to change it. How about

sprintf(hookdir, "%s%s", myhandle->root, SYSHOOKDIR + 1);

with a corresponding change in the allocation above it and a comment explaining the magic number? It seems that `root` will always end in a slash and `SYSHOOKDIR` will always start with one, so I picked the one easier to remove.

-- 
David Macek

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4254 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://lists.archlinux.org/pipermail/pacman-dev/attachments/20151125/08ead1fe/attachment.p7s>


More information about the pacman-dev mailing list