* doc/coreutils.texi: Remove doubled word.
* src/targetdir.c: Explicitly mark exported function.
* tests/local.mk: This is not a root only test.
* tests/mv/vulnerable-target.sh: Use returns_.
Introduced in
v8.28-3-g44ccd1c
(For @command{cp}, @command{ln}, and @command{mv} you can also
suppress the heuristic by setting the @env{POSIXLY_CORRECT}
environment variable.) For example, if @file{/tmp/risky/d} is a
-directory whose parent @file{/tmp/risky} is is world-writable and is
+directory whose parent @file{/tmp/risky} is world-writable and is
not sticky, the command @samp{cp passwd /tmp/risky/d} fails with
a diagnostic reporting a vulnerable target directory, as an attacker
could replace @file{/tmp/risky/d} by a symbolic link to a victim
#include <targetdir.h>
#include <die.h>
-#include <dirname.h>
#include <root-uid.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <unistd.h>
+#include "system.h"
/* Check whether DIR, which the caller presumably has already verified
is a directory or a symlink to a directory, is likely to be
This function might temporarily modify the DIR string; it restores
the string to its original value before returning. */
-enum targetdir
+extern enum targetdir
targetdir_operand_type (char *restrict dir,
struct stat const *restrict dir_lstat)
{
/* If DIR ends in / or has a last component of . or .. then it is
good enough. */
if (lclen == 0 || ISSLASH (lc[lclen - 1])
- || strcmp (lc, ".") == 0 || strcmp (lc, "..") == 0)
+ || STREQ (lc, ".") || STREQ (lc, ".."))
return TARGETDIR_OK;
char lc0 = *lc;
tests/mkdir/smack-root.sh \
tests/mv/hardlink-case.sh \
tests/mv/sticky-to-xpart.sh \
- tests/mv/vulnerable-target.sh \
tests/rm/fail-2eperm.sh \
tests/rm/no-give-up.sh \
tests/rm/one-file-system.sh \
tests/mv/to-symlink.sh \
tests/mv/trailing-slash.sh \
tests/mv/update.sh \
+ tests/mv/vulnerable-target.sh \
tests/readlink/can-e.sh \
tests/readlink/can-f.sh \
tests/readlink/can-m.sh \
mkdir risky/d || framework_failure_
echo foo >foo || framework_failure_
-mv foo risky/d && fail=1
+returns_ 1 mv foo risky/d || fail=1
mv foo risky/d/ || fail=1
mv risky/d/foo . || fail=1
mv -t risky/d foo || fail=1