diff -Naur cups-1.3.2.orig/cups/usersys.c cups-1.3.2/cups/usersys.c --- cups-1.3.2.orig/cups/usersys.c 2007-07-12 01:46:42 +0400 +++ cups-1.3.2/cups/usersys.c 2007-09-28 18:41:37 +0400 @@ -154,6 +154,26 @@ _cupsGlobals()->encryption = e; } +static +int socket_access(const char* name) +{ + struct sockaddr_un s_un; + int sock = -1; + int ret = 0; + + bzero(&s_un, sizeof(s_un)); + + strncpy(s_un.sun_path, name,sizeof s_un.sun_path); + s_un.sun_family = AF_UNIX; + + if (((sock = socket(AF_UNIX, SOCK_STREAM, 0)) > 0) && + (connect(sock, (struct sockaddr *)&s_un,SUN_LEN(&s_un)) == 0)) + ret = 1; + + if (sock >= 0) close(sock); + return ret; +} + /* * 'cupsServer()' - Return the hostname/address of the default server. @@ -201,8 +221,7 @@ * domain socket if it exists and has the right permissions... */ - if (!stat(CUPS_DEFAULT_DOMAINSOCKET, &sockinfo) && - (sockinfo.st_mode & S_IRWXO) == S_IRWXO) + if (socket_access(CUPS_DEFAULT_DOMAINSOCKET)) server = CUPS_DEFAULT_DOMAINSOCKET; else #endif /* CUPS_DEFAULT_DOMAINSOCKET */ @@ -236,6 +255,9 @@ } } +/* don't mix set and get operations, otherwise we will have a problems in sequence like: + getCups, setuid, getCups */ +#if 0 /* * Copy the server name over and set the port number, if any... */ @@ -257,6 +279,8 @@ strcpy(cg->servername, "localhost"); else strlcpy(cg->servername, cg->server, sizeof(cg->servername)); +#endif + return server; } return (cg->server); diff -Naur cups-1.3.2.orig/scheduler/listen.c cups-1.3.2/scheduler/listen.c --- cups-1.3.2.orig/scheduler/listen.c 2007-08-13 21:20:14 +0400 +++ cups-1.3.2/scheduler/listen.c 2007-09-28 18:41:45 +0400 @@ -304,7 +304,11 @@ cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s on fd %d...", s, lis->fd); - if (chmod(s, 0140777)) + if (chmod(s, 0770)) + cupsdLogMessage(CUPSD_LOG_ERROR, + "Unable to change permisssions on domain socket " + "\"%s\" - %s", s, strerror(errno)); + if (chown(s, 0,Group)) cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to change permisssions on domain socket " "\"%s\" - %s", s, strerror(errno));