diff options
author | Aaron Plattner <aplattner@nvidia.com> | 2008-02-13 10:22:35 -0800 |
---|---|---|
committer | Aaron Plattner <aplattner@nvidia.com> | 2008-02-13 10:22:35 -0800 |
commit | 8f23e2837e2dc8ce407287b2d0c45d20c06f8063 (patch) | |
tree | 191ba743512ff4ef7b5cd6e35ee24fc52b340a68 | |
parent | 19a4db4fbc69dd37dcaa6d2f211d5551e230618e (diff) |
1.0-71851.0-7185
-rw-r--r-- | DRIVER_VERSION | 2 | ||||
-rw-r--r-- | backup.c | 14 | ||||
-rw-r--r-- | command-list.c | 4 | ||||
-rw-r--r-- | files.c | 278 | ||||
-rw-r--r-- | kernel.c | 41 | ||||
-rw-r--r-- | misc.c | 51 | ||||
-rw-r--r-- | nvidia-installer.c | 2 | ||||
-rw-r--r-- | nvidia-installer.h | 1 | ||||
-rw-r--r-- | option_table.h | 33 |
9 files changed, 268 insertions, 158 deletions
diff --git a/DRIVER_VERSION b/DRIVER_VERSION index 8b58b54..4ae16bf 100644 --- a/DRIVER_VERSION +++ b/DRIVER_VERSION @@ -1 +1 @@ -1.0-7184 +1.0-7185 @@ -618,14 +618,14 @@ static int do_uninstall(Options *op) if (!nvrename(op, tmpstr, e->filename)) { ui_warn(op, "Unable to restore file '%s'.", e->filename); } else { - if (chmod(e->filename, e->mode) == -1) { - ui_warn(op, "Unable to restore permissions %04o for " - "file '%s'.", e->mode, e->filename); + if (chown(e->filename, e->uid, e->gid)) { + ui_warn(op, "Unable to restore owner (%d) and group " + "(%d) for file '%s' (%s).", + e->uid, e->gid, e->filename, strerror(errno)); } else { - if (chown(e->filename, e->uid, e->gid)) { - ui_warn(op, "Unable to restore owner (%d) and group " - "(%d) for file '%s' (%s).", - e->uid, e->gid, e->filename, strerror(errno)); + if (chmod(e->filename, e->mode) == -1) { + ui_warn(op, "Unable to restore permissions %04o for " + "file '%s'.", e->mode, e->filename); } } } diff --git a/command-list.c b/command-list.c index d973e5b..b35975e 100644 --- a/command-list.c +++ b/command-list.c @@ -228,8 +228,8 @@ CommandList *build_command_list(Options *op, Package *p) if (op->selinux_enabled && ((p->entries[i].flags & FILE_TYPE_SHARED_LIB) || (p->entries[i].flags & FILE_TYPE_XMODULE_SHARED_LIB))) { - tmp = nvstrcat(op->utils[CHCON], " -t shlib_t ", p->entries[i].dst, - NULL); + tmp = nvstrcat(op->utils[CHCON], " -t ", op->selinux_chcon_type, + " ", p->entries[i].dst, NULL); add_command(c, RUN_CMD, tmp); nvfree(tmp); } @@ -49,8 +49,7 @@ static char *get_xdg_data_dir(void); -static int get_x_library_path(Options *op); -static int get_x_module_path(Options *op); +static void get_x_library_and_module_paths(Options *op); /* @@ -746,9 +745,8 @@ int get_prefixes (Options *op) * after the default prefixes/paths are assigned. */ - if (!get_x_library_path(op) || !get_x_module_path(op)) { - return FALSE; - } + get_x_library_and_module_paths(op); + if (op->expert) { ret = ui_get_input(op, op->x_library_path, @@ -1858,8 +1856,8 @@ int set_security_context(Options *op, const char *filename) return TRUE; } - cmd = nvstrcat(op->utils[CHCON], " -t shlib_t ", filename, - NULL); + cmd = nvstrcat(op->utils[CHCON], " -t ", op->selinux_chcon_type, " ", + filename, NULL); ret = run_command(op, cmd, NULL, FALSE, 0, TRUE); @@ -1973,168 +1971,178 @@ static char *get_xdg_data_dir(void) /* - * get_x_library_path() - assign op->x_library_path if it is not - * already set. + * get_x_paths_helper() - helper function for determining the X + * library and module paths; returns 'TRUE' if we had to guess at the + * path */ -static int get_x_library_path(Options *op) +static int get_x_paths_helper(Options *op, + int library, + char *xserver_cmd, + char *pkg_config_cmd, + char *name, + char **path) { - char *cmd, *dir = NULL; - int ret; + char *dir, *cmd; + int ret, guessed = 0; /* * if the path was already specified (i.e.: by a command - * line option), then we are done. + * line option), then we are done with this iteration + */ + + if (*path != NULL) { + return FALSE; + } + + /* + * attempt to determine the path through the various query mechanisms + * + * xorg-server >= 1.3 has a stupid version number regression because the + * reported Xorg version was tied to the server version, meaning what used + * to report 7.2 now reports, for example, 1.2.99.903. This means we set + * op->modular_xorg to FALSE. However, any server with this regression will + * also support the -showDefaultModulePath option so we should still be able + * to get the right path. */ - if (op->x_library_path != NULL) - return TRUE; - - if (!op->utils[PKG_CONFIG]) { - if (op->modular_xorg) { - ui_warn(op, "You appear to be using a modular Xorg " - "release, but nvidia-installer could not find the " - "`pkg-config` utility required to determine the " - "correct X library installation path. Please " - "install the `pkg-config` utility and the Xorg " - "SDK/development package for your distribution."); - } - } else { - /* ask pkg-config */ - - cmd = nvstrcat(op->utils[PKG_CONFIG], - " --variable=libdir xorg-server", NULL); + /* + * first, try the X server commandline option; this is the + * recommended query mechanism as of X.Org 7.2 + */ + if (op->utils[XSERVER]) { + dir = NULL; + cmd = nvstrcat(op->utils[XSERVER], " ", xserver_cmd, NULL); ret = run_command(op, cmd, &dir, FALSE, 0, TRUE); nvfree(cmd); - if ((ret != 0) || (dir == NULL)) { - if (op->modular_xorg) { - ui_warn(op, "You appear to be using a modular Xorg " - "release, but nvidia-installer was unable to " - "determine the correct X library " - "installation path with the `pkg-config` " - "utility. Please install the Xorg SDK/" - "development package for your distribution."); - } - } else { - if (!directory_exists(op, dir) && - op->modular_xorg) { - ui_warn(op, "You appear to be using a modular Xorg " - "release, but the X library installation " - "path reported by `pkg-config " - "--variable=libdir xorg-server` does " - "not exist. Please check your Xorg installation."); - } else { - op->x_library_path = dir; - return TRUE; - } - } - - nvfree(dir); - } - - /* build the X library path */ - - op->x_library_path = nvstrcat(op->x_prefix, "/", op->x_libdir, NULL); - - remove_trailing_slashes(op->x_library_path); - collapse_multiple_slashes(op->x_library_path); - - if (op->modular_xorg) { - ui_warn(op, "nvidia-installer was unable to determine the " - "correct X library installation path and will " - "install the NVIDIA X libraries to '%s'.", - op->x_library_path); - } + if ((ret == 0) && dir) { - return TRUE; + if (directory_exists(op, dir)) { -} /* get_x_library_path() */ + ui_expert(op, "X %s path '%s' determined from `%s %s`", + name, dir, op->utils[XSERVER], xserver_cmd); + *path = dir; + return FALSE; -/* - * get_x_module_path() - assign op->x_module_path if it is not - * already set. - */ + } else { + ui_warn(op, "You appear to be using a modular X.Org " + "release, but the X %s installation " + "path reported by `%s %s` does not exist. " + "Please check your X.Org installation.", + name, op->utils[XSERVER], xserver_cmd); + } + } -static int get_x_module_path(Options *op) -{ - char *cmd, *dir = NULL; - int ret; + nvfree(dir); + } /* - * if the path was already specified (ie: by a commandline - * option), then we are done + * then, try the pkg-config command; this was the the + * pseudo-recommended query mechanism between X.Org 7.0 and + * X.Org 7.2 */ + if (op->utils[PKG_CONFIG]) { - if (op->x_module_path) { - return TRUE; - } + dir = NULL; + cmd = nvstrcat(op->utils[PKG_CONFIG], " ", + pkg_config_cmd, NULL); + ret = run_command(op, cmd, &dir, FALSE, 0, TRUE); + nvfree(cmd); - if (!op->utils[PKG_CONFIG]) { - if (op->modular_xorg) { - ui_warn(op, "You appear to be using a modular Xorg " - "release, but nvidia-installer could not find the " - "`pkg-config` utility required to determine the " - "correct X module installation path. Please " - "install the `pkg-config` utility and the Xorg " - "SDK/development package for your distribution."); - } - } else { - /* ask pkg-config */ + if ((ret == 0) && dir) { - cmd = nvstrcat(op->utils[PKG_CONFIG], - " --variable=moduledir xorg-server", - NULL); + if (directory_exists(op, dir)) { - ret = run_command(op, cmd, &dir, FALSE, 0, TRUE); - nvfree(cmd); + ui_expert(op, "X %s path '%s' determined from `%s %s`", + name, dir, op->utils[PKG_CONFIG], + pkg_config_cmd); + + *path = dir; + return FALSE; - if ((ret != 0) || (dir == NULL)) { - if (op->modular_xorg) { - ui_warn(op, "You appear to be using a modular Xorg " - "release, but nvidia-installer was unable to " - "determine the correct X module " - "installation path with the `pkg-config` " - "utility. Please install the Xorg SDK/" - "development package for your distribution."); - } - } else { - if (!directory_exists(op, dir) && - op->modular_xorg) { - ui_warn(op, "You appear to be using a modular Xorg " - "release, but the X module installation " - "path reported by `pkg-config " - "--variable=moduledir xorg-server` does " - "not exist. Please check your Xorg installation."); } else { - op->x_module_path = dir; - return TRUE; + ui_warn(op, "You appear to be using a modular X.Org " + "release, but the X %s installation " + "path reported by `%s %s` does not exist. " + "Please check your X.Org installation.", + name, op->utils[PKG_CONFIG], pkg_config_cmd); } } - + nvfree(dir); } - /* build the X module path */ + /* + * neither of the above mechanisms yielded a usable path; fall + * through to constructing the path by hand. If this is a modular X server, + * record that we have to guess the path so that we can print a warning when + * we are done. For non-modular X, the default of /usr/X11R6/lib is + * standard. + */ - op->x_module_path = - nvstrcat(op->x_library_path, "/", op->x_moddir, NULL); + if (op->modular_xorg) + guessed = TRUE; - remove_trailing_slashes(op->x_module_path); - collapse_multiple_slashes(op->x_module_path); - if (op->modular_xorg) { - ui_warn(op, "nvidia-installer was unable to determine the " - "correct X module installation path and will " - "install the NVIDIA X driver components to '%s'. " - "If X fails to find the NVIDIA X driver module, " - "please correct any `pkg-config` problems warned " - "about earlier and reinstall the driver.", - op->x_module_path); + /* build the path */ + + if (library) { + *path = nvstrcat(op->x_prefix, "/", op->x_libdir, NULL); + } else { + *path = nvstrcat(op->x_library_path, "/", op->x_moddir, NULL); } - return TRUE; + remove_trailing_slashes(*path); + collapse_multiple_slashes(*path); + + return guessed; +} + -} /* get_x_module_path() */ +/* + * get_x_library_and_module_paths() - assign op->x_library_path and + * op->x_module_path; this cannot fail. + */ + +static void get_x_library_and_module_paths(Options *op) +{ + int guessed = FALSE; + + /* + * get the library path, and then get the module path; note that + * the module path depends on already having the library path + */ + + guessed |= get_x_paths_helper(op, + TRUE, + "-showDefaultLibPath", + "--variable=libdir xorg-server", + "library", + &op->x_library_path); + + guessed |= get_x_paths_helper(op, + FALSE, + "-showDefaultModulePath", + "--variable=moduledir xorg-server", + "module", + &op->x_module_path); + + /* + * done assigning op->x_library_path and op->x_module_path; if we + * had to guess at either of the paths, print a warning + */ + + if (guessed) { + ui_warn(op, "nvidia-installer was forced to guess the X library " + "path '%s' and X module path '%s'; these paths were not " + "queryable from the system. If X fails to find the " + "NVIDIA X driver module, please install the `pkg-config` " + "utility and the X.Org SDK/development package for your " + "distribution and reinstall the driver.", + op->x_library_path, op->x_module_path); + } + +} /* get_x_library_and_module_paths() */ @@ -55,6 +55,7 @@ static int rmmod_kernel_module(Options *op, const char *); static PrecompiledInfo *download_updated_kernel_interface(Options*, Package*, const char*); static int fbdev_check(Options *op, Package *p); +static int xen_check(Options *op, Package *p); static PrecompiledInfo *scan_dir(Options *op, Package *p, const char *directory_name, @@ -445,6 +446,7 @@ int build_kernel_module(Options *op, Package *p) } if (!fbdev_check(op, p)) return FALSE; + if (!xen_check(op, p)) return FALSE; cmd = nvstrcat("cd ", p->kernel_module_build_directory, "; make print-module-filename", @@ -1576,12 +1578,49 @@ static int fbdev_check(Options *op, Package *p) return TRUE; - } /* fbdev_check() */ /* + * xen_check() - run the xen_sanity_check conftest; if this test fails, print + * the test's error message and abort the driver installation. + */ + +static int xen_check(Options *op, Package *p) +{ + char *CC, *cmd, *result; + int ret; + + CC = getenv("CC"); + if (!CC) CC = "cc"; + + ui_log(op, "Performing Xen check."); + + cmd = nvstrcat("sh ", p->kernel_module_build_directory, + "/conftest.sh ", CC, " ", CC, " ", + op->kernel_source_path, " ", + op->kernel_output_path, " ", + "xen_sanity_check just_msg", NULL); + + ret = run_command(op, cmd, &result, FALSE, 0, TRUE); + + nvfree(cmd); + + if (ret != 0) { + ui_error(op, "%s", result); + nvfree(result); + + return FALSE; + } + + return TRUE; + +} /* xen_check() */ + + + +/* * scan_dir() - scan through the specified directory for a matching * precompiled kernel interface. */ @@ -2089,7 +2089,56 @@ int check_selinux(Options *op) } break; } - + + /* Figure out which chcon type we need if the user didn't supply one. */ + if (op->selinux_enabled && !op->selinux_chcon_type) { + unsigned char foo = 0; + char *tmpfile; + static const char* chcon_types[] = { + "textrel_shlib_t", /* Shared library with text relocations */ + "texrel_shlib_t", /* Obsolete synonym for the above */ + "shlib_t", /* Generic shared library */ + NULL + }; + + /* Create a temporary file */ + tmpfile = write_temp_file(op, 1, &foo, S_IRUSR); + if (!tmpfile) { + ui_warn(op, "Couldn't test chcon. Assuming shlib_t."); + op->selinux_chcon_type = "shlib_t"; + } else { + int i, ret; + char *cmd; + + /* Try each chcon command */ + for (i = 0; chcon_types[i]; i++) { + cmd = nvstrcat(op->utils[CHCON], " -t ", chcon_types[i], " ", + tmpfile, NULL); + ret = run_command(op, cmd, NULL, FALSE, 0, TRUE); + nvfree(cmd); + + if (ret == 0) break; + } + + if (!chcon_types[i]) { + /* None of them work! */ + ui_warn(op, "Couldn't find a working chcon argument. " + "Defaulting to shlib_t."); + op->selinux_chcon_type = "shlib_t"; + } else { + op->selinux_chcon_type = chcon_types[i]; + } + + unlink(tmpfile); + nvfree(tmpfile); + } + } + + if (op->selinux_enabled) { + ui_log(op, "Tagging shared libraries with chcon -t %s.", + op->selinux_chcon_type); + } + return TRUE; } /* check_selinux */ /* diff --git a/nvidia-installer.c b/nvidia-installer.c index e641005..5fd7d63 100644 --- a/nvidia-installer.c +++ b/nvidia-installer.c @@ -412,6 +412,8 @@ Options *parse_commandline(int argc, char *argv[]) exit(1); } break; + case SELINUX_CHCON_TYPE_OPTION: + op->selinux_chcon_type = optarg; break; case NO_SIGWINCH_WORKAROUND_OPTION: op->sigwinch_workaround = FALSE; break; diff --git a/nvidia-installer.h b/nvidia-installer.h index fc50879..c02e887 100644 --- a/nvidia-installer.h +++ b/nvidia-installer.h @@ -178,6 +178,7 @@ typedef struct __options { char *kernel_name; char *rpm_file_list; char *precompiled_kernel_interfaces_path; + const char *selinux_chcon_type; Distribution distro; diff --git a/option_table.h b/option_table.h index 4dad438..fa7ecd5 100644 --- a/option_table.h +++ b/option_table.h @@ -45,6 +45,7 @@ enum { COMPAT32_LIBDIR_OPTION, UPDATE_OPTION, FORCE_SELINUX_OPTION, + SELINUX_CHCON_TYPE_OPTION, NO_SIGWINCH_WORKAROUND_OPTION, X_MODULE_PATH_OPTION, DOCUMENTATION_PREFIX_OPTION, @@ -126,18 +127,21 @@ static const NVOption __options[] = { { "x-module-path", X_MODULE_PATH_OPTION, NVOPT_HAS_ARGUMENT, "The path under which the NVIDIA X server modules will be installed. " - "If `pkg-config --variable=moduledir xorg-server` is successful and " - "returns a directory that exists, then that is the default; otherwise, " - "this value defaults to the X library path (see the '--x-library-path' " - "option) plus '" DEFAULT_X_MODULEDIR "' or '" XORG7_DEFAULT_X_MODULEDIR - "' if nvidia-installer detects that Xorg >= 7.0 is installed." }, + "If this option is not specified, nvidia-installer uses the following " + "search order and selects the first valid directory it finds: 1) " + "`X -showDefaultModulePath`, 2) `pkg-config --variable=moduledir " + "xorg-server`, or 3) the X library path (see the '--x-library-path' " + "option) plus either '" DEFAULT_X_MODULEDIR "' (for X servers older " + "than X.Org 7.0) or '" XORG7_DEFAULT_X_MODULEDIR "' (for X.Org 7.0 or " + "later)." }, { "x-library-path", X_LIBRARY_PATH_OPTION, NVOPT_HAS_ARGUMENT, "The path under which the NVIDIA X libraries will be installed. " - "If `pkg-config --variable=libdir xorg-server` is successful and " - "returns a directory that exists, then that is the default; otherwise, " - "this value defaults to the X prefix (see the '--x-prefix' option) " - "plus '" DEFAULT_LIBDIR "' on 32bit systems, and '" + "If this option is not specified, nvidia-installer uses the following " + "search order and selects the first valid directory it finds: 1) " + "`X -showDefaultLibPath`, 2) `pkg-config --variable=libdir " + "xorg-server`, or 3) the X prefix (see the '--x-prefix' option) " + "plus '" DEFAULT_LIBDIR "' on 32bit systems, and either '" DEFAULT_64BIT_LIBDIR "' or '" DEFAULT_LIBDIR "' on 64bit systems, " "depending on the installed Linux distribution." }, @@ -379,7 +383,8 @@ static const NVOption __options[] = { { "force-selinux", FORCE_SELINUX_OPTION, NVOPT_HAS_ARGUMENT, "Linux installations using SELinux (Security-Enhanced Linux) " "require that the security type of all shared libraries be set " - "to 'shlib_t'. nvidia-installer will detect when to set " + "to 'shlib_t' or 'textrel_shlib_t', depending on the distribution. " + "nvidia-installer will detect when to set " "the security type, and set it using chcon(1) on the shared " "libraries it installs. Use this option to override " "nvidia-installer's detection of when to set the security type. " @@ -387,7 +392,13 @@ static const NVOption __options[] = { "security type), " "'no' (prevent setting of the security type), and 'default' " "(let nvidia-installer decide when to set the security type)." }, - + + { "selinux-chcon-type", SELINUX_CHCON_TYPE_OPTION, NVOPT_HAS_ARGUMENT, + "When SELinux support is enabled, nvidia-installer will try to determine " + "which chcon argument to use by first trying 'textrel_shlib_t', then " + "'texrel_shlib_t', then 'shlib_t'. Use this option to override this " + "detection logic." }, + { "no-sigwinch-workaround", NO_SIGWINCH_WORKAROUND_OPTION, 0, "Normally, nvidia-installer ignores the SIGWINCH signal before it " "forks to execute commands, e.g. to build the kernel module, and " |