setlabel.c revision f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* setlabel - sets a file label.
*/
#include <errno.h>
#include <fcntl.h>
#include <locale.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <utmp.h>
static int set_label(char *, char *);
static void usage(void);
static void m_label_err(const char *, const int);
int
{
int rc = 0;
char *label;
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
#endif
(void) textdomain(TEXT_DOMAIN);
else
prog++;
if (argc < 3) {
usage();
return (2);
}
argv++;
argc--;
argv++;
argc--;
while (argc-- > 0) {
rc = 1;
}
return (rc);
}
static int
{
int rval = 0;
int err;
return (2);
}
if (rval) {
return (rval);
}
gettext("%s: Current label is invalid\n"),
filename);
}
}
if (rval == 0)
return (rval);
}
static int
{
int rval;
if (rval) {
}
return (rval);
}
static void
{
switch (err) {
case M_BAD_STRING:
break;
case M_BAD_LABEL:
gettext("setlabel: bad previous label\n"));
break;
default:
gettext("setlabel: parsing error found in "
break;
}
} else {
perror("setlabel");
}
exit(1);
}
/*
* usage()
*
* This routine is called whenever there is a usage type of error has
* occured. For example, when a invalid option has has been specified.
*
*/
static void
usage(void)
{
" %s newlabel filename [...] \n"), prog);
}