misc.c revision c1ecd8b9404ee0d96d93f02e82c441b9bb149a3d
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <pwd.h>
#include <time.h>
#include <syslog.h>
#include <errno.h>
#include <misc.h>
#include <job.h>
#include <list.h>
/*
* info about spool directory that we validate and fix
*/
#define ROOT_UID 0
#define LP_GID 8
/*ARGSUSED*/
int
check_client_spool(char *printer)
{
return (-1);
}
return (-1);
}
return (0);
}
return (-1);
}
}
"spool dir (%s), incorrect permission (%0), correcting",
return (-1);
}
}
return (0);
}
int
{
int fd;
return (fd);
return (-1);
}
if (write_pid != 0) {
char pid[16];
return (-1);
}
>= sizeof (pid)) {
return (-1);
}
}
return (fd);
}
get_user_id(char *name)
{
return (-1);
return (p->pw_uid);
return (p->pw_uid);
else
return (-2);
}
/*
* get_user_name()
*/
char *
{
else
return (strdup("unknown"));
}
/*
* strcdup() - duplicate a string up to the first occurence of a character
*/
char *
strcdup(char *p, char c)
{
char *q,
*r;
if (p == NULL)
return (NULL);
return (strdup(p));
(void) strlcpy(r, p, ((q - p) + 1));
return (r);
}
/*
* Should be obvious
*/
char *
strndup(char *s, int l)
{
char *t;
if ((s == NULL) || (l < 1))
return (NULL);
(void) strlcpy(t, s, (l + 1));
return (t);
}
/*
* file_size() - need I say more
*/
int
{
return (-1);
else
}
/*
* copy_file() - need I say more
*/
int
{
char *buf;
int size;
return (-1);
return (-1);
return (-1);
}
return (0);
}
int
backup_file(char *name)
{
return (-1);
}
}
/*
* map_in_file() - mmaps in a file into a buffer *buf. returns the size of
* the mmapped buffer.
*/
int
{
int fd;
return (-1);
if (as_me != 0)
return (-1);
if (as_me != 0)
seteuid(0); /* if we fail, didn't have privilege before */
return (-1);
}
return (0);
}
(MAP_PRIVATE | MAP_NORESERVE),
return (-1);
}
}
/*
* write_buffer() - writes a buffer in memory out to the file name passed in.
* uses mmap and ftruncate to do this.
*/
int
{
int fd;
char *tmp;
return (-1);
return (-1);
}
(MAP_SHARED | MAP_NORESERVE),
return (-1);
}
return (0);
}
/*
* start_daemon() - check for jobs queued, check if the lock is free. If
* so, start a daemon either by forking and execing or just execing
* depending on the flag passed in.
*/
void
start_daemon(int do_fork)
{
int lock;
return;
if (lock < 0)
return;
if (do_fork == 0) {
exit(-1);
} else
switch (fork()) {
case -1:
exit(-1);
/* NOTREACHED */
case 0:
break;
default:
NULL);
exit(-1);
/* NOTREACHED */
}
}
/*
* kill_daemon() - read the master lock file and send SIGTERM to the process
* id stored in the file.
*/
int
kill_process(char *file)
{
int fd,
pid;
*p;
return (-1);
return (-1);
return (-1);
}
return (-1);
}
return (0);
}
char **
{
char *element;
return (list);
}