Annotation of embedaddon/sudo/src/sesh.c, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (c) 2008, 2010 Todd C. Miller <Todd.Miller@courtesan.com>
3: *
4: * Permission to use, copy, modify, and distribute this software for any
5: * purpose with or without fee is hereby granted, provided that the above
6: * copyright notice and this permission notice appear in all copies.
7: *
8: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
16: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17: */
18:
19: #include <config.h>
20:
21: #include <sys/types.h>
22: #include <err.h>
23: #include <errno.h>
24: #include <limits.h>
25: #include <stdio.h>
26: #include <stdlib.h>
27: #include <string.h>
28: #include <unistd.h>
29: #ifdef HAVE_SETLOCALE
30: # include <locale.h>
31: #endif
32:
33: #include "missing.h"
34: #include "gettext.h"
35:
36: int
37: main (int argc, char *argv[])
38: {
39: char *cp, *cmnd;
40:
41: #ifdef HAVE_SETLOCALE
42: setlocale(LC_ALL, "");
43: #endif
44: bindtextdomain(PACKAGE_NAME, LOCALEDIR);
45: textdomain(PACKAGE_NAME);
46:
47: if (argc < 2)
48: errx(EXIT_FAILURE, _("requires at least one argument"));
49:
50: /* Shift argv and make a copy of the command to execute. */
51: argv++;
52: argc--;
53: cmnd = strdup(argv[0]);
54: if (cmnd == NULL)
55: err(EXIT_FAILURE, NULL);
56:
57: /* If invoked as a login shell, modify argv[0] accordingly. */
58: if (argv[0][0] == '-') {
59: if ((cp = strrchr(argv[0], '/')) == NULL)
60: cp = argv[0];
61: *cp = '-';
62: }
63: execv(cmnd, argv);
64: warn(_("unable to execute %s"), argv[0]);
65: _exit(EXIT_FAILURE);
66: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>