X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=scheduler%2Fenv.c;h=71ab98d6b8b642f704e061a77d2fa4dd46bf3d39;hb=dc84a5a4cdb6900256a6ea9f627336bc19903dcc;hp=0b66b5e22df145e19b230ca23f30c180b221ee5e;hpb=0268488e2f31bbec0c6b02ff7b7594b3191e6177;p=thirdparty%2Fcups.git diff --git a/scheduler/env.c b/scheduler/env.c index 0b66b5e22..71ab98d6b 100644 --- a/scheduler/env.c +++ b/scheduler/env.c @@ -1,27 +1,10 @@ /* - * "$Id: env.c 7673 2008-06-18 22:31:26Z mike $" + * Environment management routines for the CUPS scheduler. * - * Environment management routines for the CUPS scheduler. + * Copyright 2007-2016 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products, all rights reserved. * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products, all rights reserved. - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * cupsdInitEnv() - Initialize the current environment with standard - * variables. - * cupsdLoadEnv() - Copy common environment variables into an array. - * cupsdSetEnv() - Set a common environment variable. - * cupsdSetEnvf() - Set a formatted common environment variable. - * cupsdUpdateEnv() - Update the environment for the configured directories. - * clear_env() - Clear common environment variables. - * find_env() - Find a common environment variable. + * Licensed under Apache License v2.0. See the file "LICENSE" for more information. */ /* @@ -62,7 +45,7 @@ cupsdInitEnv(void) #if defined(__APPLE__) /* - * Add special voodoo magic for MacOS X - this allows MacOS X + * Add special voodoo magic for macOS - this allows macOS * programs to access their bundle resources properly... * * This string is replaced in cupsdStartProcess()... @@ -130,6 +113,13 @@ cupsdSetEnv(const char *name, /* I - Name of variable */ if (!value) return; + /* + * Do not allow dynamic linker variables when running as root... + */ + + if (!RunUser && (!strncmp(name, "DYLD_", 5) || !strncmp(name, "LD_", 3))) + return; + /* * See if this variable has already been defined... */ @@ -211,6 +201,7 @@ cupsdUpdateEnv(void) set_if_undefined("CUPS_SERVERBIN", ServerBin); set_if_undefined("CUPS_SERVERROOT", ServerRoot); set_if_undefined("CUPS_STATEDIR", StateDir); + set_if_undefined("DYLD_INSERT_LIBRARIES", NULL); set_if_undefined("DYLD_LIBRARY_PATH", NULL); set_if_undefined("HOME", TempDir); set_if_undefined("LD_ASSUME_KERNEL", NULL); @@ -227,6 +218,8 @@ cupsdUpdateEnv(void) set_if_undefined("TZ", NULL); set_if_undefined("USER", "root"); set_if_undefined("VG_ARGS", NULL); + + cupsdSetEnvf("CUPS_MAX_MESSAGE", "%d", CUPSD_SB_BUFFER_SIZE - 1); } @@ -248,5 +241,19 @@ clear_env(void) /* - * End of "$Id: env.c 7673 2008-06-18 22:31:26Z mike $". + * 'find_env()' - Find a common environment variable. */ + +static int /* O - Index or -1 if not found */ +find_env(const char *name) /* I - Variable name */ +{ + int i; /* Looping var */ + size_t namelen; /* Length of name */ + + + for (i = 0, namelen = strlen(name); i < num_common_env; i ++) + if (!strncmp(common_env[i], name, namelen) && common_env[i][namelen] == '=') + return (i); + + return (-1); +}