nss_write.c revision 36e852a172cba914383d7341c988128b2c667fbd
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdarg.h>
#include <fcntl.h>
#include <syslog.h>
#include <errno.h>
#include <pwd.h>
#include <libintl.h>
#include <netdb.h> /* for rcmd() */
#include <ns.h>
#include <list.h>
/* escaped chars include delimiters and shell meta characters */
#define ESCAPE_CHARS "\\\n=: `&;|>^$()<*?["
/*
* This modules contains all of the code nedessary to write back to each
* printing configuration data repository. The support is intended to
* introduce the least number of dependencies in the library, so it doesn't
* always perform it's operations in the cleanest fashion.
*/
/*
* Generic Files support begins here.
*/
static char *
{
char *s = buf;
continue;
} else {
if ((*s == '#') || (*s == '\n')) {
*s = NULL;
break;
}
s += strlen(s);
if (*(s - 2) != '\\')
break;
#ifdef STRIP_CONTINUATION
buflen -= 2;
s -= 2;
#endif
}
}
if (s == buf)
return (NULL);
else
return (buf);
}
static int
{
*ofp;
char *tmpfile;
int fd;
int exit_status = 0;
int size;
return (-1);
return (-1);
}
/* LINTED */
while (1) { /* syncronize writes */
if (fd < 0) {
continue;
return (-1);
}
break;
}
return (-1);
}
return (-1);
}
char buf[4096];
"#\n#\tIf you hand edit this file, comments and structure may change.\n"
"#\tThe preferred method of modifying this file is through the use of\n"
"#\tlpset(1M)\n#\n");
/*
* Handle the special case of lpset -x all
* This deletes all entries in the file
* In this case, just don't write any entries to the tmpfile
*/
== 0) {
} else
}
free(t);
}
} else {
exit_status = -1;
}
return (exit_status);
}
/*
* Support for writing a printer into the FILES /etc/printers.conf
* file.
*/
int
{
static char *file = "/etc/printers.conf";
}
/*
* Support for writing a printer into the NIS printers.conf.byname
* map.
*/
/*
* Run the remote command. We aren't interested in any io, Only the
* return code.
*/
static int
{
int fd;
return (-1);
return (0);
} else
return (-1);
}
/*
* This isn't all that pretty, but you can update NIS if the machine this
* runs on is in the /.rhosts or /etc/hosts.equiv on the NIS master.
* copy it local, update it, copy it remote
*/
#define TMP_PRINTERS_FILE "/tmp/printers.NIS"
#define NIS_MAKEFILE "/var/yp/Makefile"
#define MAKE_EXCERPT "/usr/lib/print/Makefile.yp"
/*ARGSUSED*/
int
{
char *map = "printers.conf.byname";
(void) yp_get_default_domain(&domain);
return (-1);
sizeof (lfile)) {
return (-1);
}
sizeof (rfile)) {
return (-1);
}
/* copy it local */
"nis_put_printer:buffer overflow building cmd");
return (-1);
}
/* update it */
return (-1);
/* copy it back */
"nis_put_printer:buffer overflow building cmd");
return (-1);
}
return (-1);
/* copy the Makefile excerpt */
"nis_put_printer:buffer overflow building cmd");
return (-1);
}
return (-1);
/* run the make */
"make -f %s -f %s.print printers.conf >/dev/null 2>&1'",
"nis_put_printer:buffer overflow on make");
return (-1);
}
}