aboutsummaryrefslogtreecommitdiff
path: root/sbin/ldconfig/elfhints.c
diff options
context:
space:
mode:
authorJohn Polstra <jdp@FreeBSD.org>2000-08-07 19:12:04 +0000
committerJohn Polstra <jdp@FreeBSD.org>2000-08-07 19:12:04 +0000
commit643dcf40ee22ff8776918913e2c7ff6c9c0c4be8 (patch)
treec046e17537403f7434738524e45ea6cb70d0c96b /sbin/ldconfig/elfhints.c
parent1623d68286c88f545c37fe19c78662b6abc5bd90 (diff)
downloadsrc-643dcf40ee22ff8776918913e2c7ff6c9c0c4be8.tar.gz
src-643dcf40ee22ff8776918913e2c7ff6c9c0c4be8.zip
Add a "-i" option ("insecure") which disables the checks for
root ownership, etc. I will soon commit a companion knob for "/etc/rc.conf". Submitted by: Maxime Henrion <mhenrion@cybercable.fr>
Notes
Notes: svn path=/head/; revision=64360
Diffstat (limited to 'sbin/ldconfig/elfhints.c')
-rw-r--r--sbin/ldconfig/elfhints.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/sbin/ldconfig/elfhints.c b/sbin/ldconfig/elfhints.c
index f7139dfcb0a0..7e5c8e5081bb 100644
--- a/sbin/ldconfig/elfhints.c
+++ b/sbin/ldconfig/elfhints.c
@@ -46,7 +46,7 @@
#define MAXDIRS 1024 /* Maximum directories in path */
#define MAXFILESIZE (16*1024) /* Maximum hints file size */
-static void add_dir(const char *, const char *);
+static void add_dir(const char *, const char *, int);
static void read_dirs_from_file(const char *, const char *);
static void read_elf_hints(const char *, int);
static void write_elf_hints(const char *);
@@ -55,23 +55,25 @@ static const char *dirs[MAXDIRS];
static int ndirs;
static void
-add_dir(const char *hintsfile, const char *name)
+add_dir(const char *hintsfile, const char *name, int trusted)
{
struct stat stbuf;
int i;
/* Do some security checks */
- if (stat(name, &stbuf) == -1) {
- warn("%s", name);
- return;
- }
- if (stbuf.st_uid != 0) {
- warnx("%s: not owned by root", name);
- return;
- }
- if ((stbuf.st_mode & S_IWOTH) != 0) {
- warnx("%s: ignoring world-writable directory", name);
- return;
+ if (!trusted && !insecure) {
+ if (stat(name, &stbuf) == -1) {
+ warn("%s", name);
+ return;
+ }
+ if (stbuf.st_uid != 0) {
+ warnx("%s: ignoring directory not owned by root", name);
+ return;
+ }
+ if ((stbuf.st_mode & S_IWOTH) != 0) {
+ warnx("%s: ignoring world-writable directory", name);
+ return;
+ }
}
for (i = 0; i < ndirs; i++)
@@ -170,7 +172,7 @@ read_dirs_from_file(const char *hintsfile, const char *listfile)
if ((sp = strdup(sp)) == NULL)
errx(1, "Out of memory");
- add_dir(hintsfile, sp);
+ add_dir(hintsfile, sp, 0);
}
fclose(fp);
@@ -218,7 +220,7 @@ read_elf_hints(const char *hintsfile, int must_exist)
if (*dirlist != '\0')
while ((p = strsep(&dirlist, ":")) != NULL)
- add_dir(hintsfile, p);
+ add_dir(hintsfile, p, 1);
}
void
@@ -236,7 +238,7 @@ update_elf_hints(const char *hintsfile, int argc, char **argv, int merge)
else if (S_ISREG(s.st_mode))
read_dirs_from_file(hintsfile, argv[i]);
else
- add_dir(hintsfile, argv[i]);
+ add_dir(hintsfile, argv[i], 0);
}
write_elf_hints(hintsfile);
}