mlisten.c (7c478bd9) mlisten.c (45916cd2)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28/* All Rights Reserved */
29
30
31#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.9 */
32# include <unistd.h>
33# include <stdlib.h>
34# include <string.h>
35# include <poll.h>
36# include <stropts.h>
37# include <fcntl.h>
38# include <errno.h>
39#include <syslog.h>
23 * Use is subject to license terms.
24 */
25
26/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27/* All Rights Reserved */
28
29
30#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.9 */
31# include <unistd.h>
32# include <stdlib.h>
33# include <string.h>
34# include <poll.h>
35# include <stropts.h>
36# include <fcntl.h>
37# include <errno.h>
38#include <syslog.h>
39#include <user_attr.h>
40#include <secdb.h>
41#include <pwd.h>
40
41# include "lp.h"
42# include "msgs.h"
43
44#define TURN_ON(X,F) (void)Fcntl(X, F_SETFL, (Fcntl(X, F_GETFL, 0)|(F)))
45
46static int NumEvents = 0;
47static int NumCons = 0;

--- 275 unchanged lines hidden (view full) ---

323
324 memset(md, 0, sizeof (MESG));
325 md->gid = recbuf.gid;
326 md->readfd = md->writefd = recbuf.fd;
327 md->state = MDS_IDLE;
328 md->type = MD_UNKNOWN;
329 md->uid = recbuf.uid;
330
42
43# include "lp.h"
44# include "msgs.h"
45
46#define TURN_ON(X,F) (void)Fcntl(X, F_SETFL, (Fcntl(X, F_GETFL, 0)|(F)))
47
48static int NumEvents = 0;
49static int NumCons = 0;

--- 275 unchanged lines hidden (view full) ---

325
326 memset(md, 0, sizeof (MESG));
327 md->gid = recbuf.gid;
328 md->readfd = md->writefd = recbuf.fd;
329 md->state = MDS_IDLE;
330 md->type = MD_UNKNOWN;
331 md->uid = recbuf.uid;
332
333 /*
334 * Determine if a print administrator is contacting lpsched.
335 * currently, root, lp and users with the "solaris.print.admin"
336 * privilege are print administrators
337 */
331 md->admin = (md->uid == 0 || md->uid == Lp_Uid);
338 md->admin = (md->uid == 0 || md->uid == Lp_Uid);
339 if (md->admin == 0) {
340 struct passwd *pw = NULL;
332
341
342 if ((pw = getpwuid(md->uid)) != NULL)
343 md->admin = chkauthattr("solaris.print.admin",
344 pw->pw_name);
345 }
346
347 get_peer_label(md->readfd, &md->slabel);
348
333 if (mlistenadd(md, POLLIN) != 0)
334 return(NULL);
335
336 ResetFifoBuffer (md->readfd);
337 /*
338 ** Reset fdp because mlistenadd may have
339 ** realloc()ed PollFdList and changed its
340 ** physical location.

--- 199 unchanged lines hidden ---
349 if (mlistenadd(md, POLLIN) != 0)
350 return(NULL);
351
352 ResetFifoBuffer (md->readfd);
353 /*
354 ** Reset fdp because mlistenadd may have
355 ** realloc()ed PollFdList and changed its
356 ** physical location.

--- 199 unchanged lines hidden ---