|
Harald Hoyer |
08211a |
From f6c2faebfafb95ae7ce14fe678582077af20c3c0 Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
08211a |
From: Harald Hoyer <harald@redhat.com>
|
|
Harald Hoyer |
08211a |
Date: Wed, 11 Jul 2012 15:47:10 +0200
|
|
Harald Hoyer |
08211a |
Subject: [PATCH] install/dracut-install.c: check for empty or "/" destdir
|
|
Harald Hoyer |
08211a |
|
|
Harald Hoyer |
08211a |
---
|
|
Harald Hoyer |
08211a |
install/dracut-install.c | 17 +++++++++++------
|
|
Harald Hoyer |
08211a |
1 file changed, 11 insertions(+), 6 deletions(-)
|
|
Harald Hoyer |
08211a |
|
|
Harald Hoyer |
08211a |
diff --git a/install/dracut-install.c b/install/dracut-install.c
|
|
Harald Hoyer |
08211a |
index ee6950a..9351472 100644
|
|
Harald Hoyer |
08211a |
--- a/install/dracut-install.c
|
|
Harald Hoyer |
08211a |
+++ b/install/dracut-install.c
|
|
Harald Hoyer |
08211a |
@@ -182,7 +182,7 @@ static int cp(const char *src, const char *dst)
|
|
Harald Hoyer |
08211a |
int pid;
|
|
Harald Hoyer |
08211a |
int ret;
|
|
Harald Hoyer |
08211a |
|
|
Harald Hoyer |
08211a |
- if(use_clone) {
|
|
Harald Hoyer |
08211a |
+ if (use_clone) {
|
|
Harald Hoyer |
08211a |
struct stat sb;
|
|
Harald Hoyer |
08211a |
int dest_desc, source_desc;
|
|
Harald Hoyer |
08211a |
|
|
Harald Hoyer |
08211a |
@@ -197,8 +197,8 @@ static int cp(const char *src, const char *dst)
|
|
Harald Hoyer |
08211a |
goto normal_copy;
|
|
Harald Hoyer |
08211a |
|
|
Harald Hoyer |
08211a |
dest_desc =
|
|
Harald Hoyer |
08211a |
- open(dst, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC,
|
|
Harald Hoyer |
08211a |
- (sb.st_mode) & (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO));
|
|
Harald Hoyer |
08211a |
+ open(dst, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC,
|
|
Harald Hoyer |
08211a |
+ (sb.st_mode) & (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO));
|
|
Harald Hoyer |
08211a |
|
|
Harald Hoyer |
08211a |
if (dest_desc < 0) {
|
|
Harald Hoyer |
08211a |
close(source_desc);
|
|
Harald Hoyer |
08211a |
@@ -379,7 +379,6 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res
|
|
Harald Hoyer |
08211a |
}
|
|
Harald Hoyer |
08211a |
}
|
|
Harald Hoyer |
08211a |
|
|
Harald Hoyer |
08211a |
-
|
|
Harald Hoyer |
08211a |
i = strdup(dst);
|
|
Harald Hoyer |
08211a |
hashmap_put(items, i, i);
|
|
Harald Hoyer |
08211a |
|
|
Harald Hoyer |
08211a |
@@ -731,15 +730,21 @@ int main(int argc, char **argv)
|
|
Harald Hoyer |
08211a |
|
|
Harald Hoyer |
08211a |
umask(0022);
|
|
Harald Hoyer |
08211a |
|
|
Harald Hoyer |
08211a |
- if (destrootdir == NULL) {
|
|
Harald Hoyer |
08211a |
+ if (destrootdir == NULL || strlen(destrootdir) == 0) {
|
|
Harald Hoyer |
08211a |
destrootdir = getenv("DESTROOTDIR");
|
|
Harald Hoyer |
08211a |
- if (destrootdir == NULL) {
|
|
Harald Hoyer |
08211a |
+ if (destrootdir == NULL || strlen(destrootdir) == 0) {
|
|
Harald Hoyer |
08211a |
log_error("Environment DESTROOTDIR or argument -D is not set!");
|
|
Harald Hoyer |
08211a |
usage(EXIT_FAILURE);
|
|
Harald Hoyer |
08211a |
}
|
|
Harald Hoyer |
08211a |
destrootdir = strdup(destrootdir);
|
|
Harald Hoyer |
08211a |
}
|
|
Harald Hoyer |
08211a |
|
|
Harald Hoyer |
08211a |
+ if (strcmp(destrootdir, "/") == 0) {
|
|
Harald Hoyer |
08211a |
+ log_error("Environment DESTROOTDIR or argument -D is set to '/'!");
|
|
Harald Hoyer |
08211a |
+ usage(EXIT_FAILURE);
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ }
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
items = hashmap_new(string_hash_func, string_compare_func);
|
|
Harald Hoyer |
08211a |
items_failed = hashmap_new(string_hash_func, string_compare_func);
|
|
Harald Hoyer |
08211a |
|