3
0
Ludwig Nussel 2021-06-02 13:25:33 +00:00 committed by Git OBS Bridge
parent 81fced0166
commit ba81243db7
2 changed files with 8 additions and 11 deletions

View File

@ -105,10 +105,4 @@ done
set +e set +e
echo "Run ldconfig." echo "Run ldconfig."
ldconfig -r "$ROOT" ldconfig -r "$ROOT" || :
#. $ROOT/etc/selinux/config
#if [ -n "$(command -v setfiles)" ] && [ "$SELINUX" != "disabled" ] && [ -f /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts ]; then
# echo "Fixing SELinux labels"
# setfiles -r $ROOT -p /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts $ROOT/sbin $ROOT/bin $ROOT/lib $ROOT/lib64 $ROOT/usr/lib $ROOT/usr/lib64 $ROOT/etc/ld.so.cache $ROOT/var/cache/ldconfig || :
#fi

11
xmv.c
View File

@ -31,6 +31,7 @@
#include <errno.h> #include <errno.h>
#include <getopt.h> #include <getopt.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h>
#ifndef RENAME_EXCHANGE #ifndef RENAME_EXCHANGE
# define RENAME_EXCHANGE (1 << 1) # define RENAME_EXCHANGE (1 << 1)
@ -74,13 +75,16 @@ int main(int argc, char** argv)
return 1; return 1;
} }
/* Fallback for systems without renameat2 support */ // Fallback for systems without renameat2 support
char *tmp; puts("!!! WARNING: rename2 RENAME_EXCHANGE not supported !!!");
r = asprintf(&tmp, "%s.XXXXXX", target); puts("!!! fallback to unsafe rename !!!");
char tmp[PATH_MAX];
r = snprintf(tmp, sizeof(tmp), "%s.XXXXXX", target);
if (r < 0) { if (r < 0) {
perror("asprintf"); perror("asprintf");
return 1; return 1;
} }
// not intended to be use in /tmp so good enough
mktemp(tmp); mktemp(tmp);
r = renameat(AT_FDCWD, target, AT_FDCWD, tmp); r = renameat(AT_FDCWD, target, AT_FDCWD, tmp);
@ -88,7 +92,6 @@ int main(int argc, char** argv)
r = renameat(AT_FDCWD, source, AT_FDCWD, target); r = renameat(AT_FDCWD, source, AT_FDCWD, target);
if (!r) if (!r)
r = renameat(AT_FDCWD, tmp, AT_FDCWD, source); r = renameat(AT_FDCWD, tmp, AT_FDCWD, source);
free(tmp);
if (r < 0) { if (r < 0) {
perror("renameat"); perror("renameat");