1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/* This file is part of GNU Pies. -*- c -*-
Copyright (C) 2016-2017 Sergey Poznyakoff
GNU Pies is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Pies is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Pies. If not, see <http://www.gnu.org/licenses/>. */
OPTIONS_COMMAND_BEGIN("pies",
[<>],
[<send command to init process via the legacy interface>],
[<[RUNLEVEL]>],
[<gnu>],
[<noversion>])
OPTION(timeout,t,[<SECONDS>],
[<set interval between sending TERM and KILL signals>])
BEGIN
char *p;
errno = 0;
shutdown_timeout = strtoul (optarg, &p, 0);
if (*p || errno)
{
logmsg (LOG_ERR, _("invalid number: %s"), optarg);
exit (EX_USAGE);
}
END
OPTION(environment,e,[<VAR=[VAL]>],[<change environment>])
BEGIN
size_t len = strlen (optarg);
if (envsize + len + 2 > sizeof(req->data))
{
logmsg (LOG_ERR, _("-e argument too long"));
exit (EX_USAGE);
}
memcpy (req->data + envsize, optarg, len);
envsize += len;
req->data[envsize++] = 0;
END
OPTIONS_END
static void
telinit_parser (struct sysvinit_request *req, int argc, char *argv[])
{
int i;
char *cmds[] = { "-T", NULL };
size_t envsize = 0;
proginfo.subcmd = cmds;
GETOPT(argc, argv, i);
argc -= i;
argv += i;
if (envsize)
{
req->data[envsize++] = 0;
req->cmd = INIT_CMD_SETENV;
if (argc)
{
logmsg (LOG_ERR, _("too many arguments"));
exit (EX_USAGE);
}
}
else
{
if (argc != 1)
{
logmsg (LOG_ERR, _("bad number of arguments"));
exit (EX_USAGE);
}
if (argv[0][1] || !is_valid_runlevel (argv[0][0]))
{
logmsg (LOG_ERR, _("invalid runlevel: %s"), argv[0]);
exit (EX_USAGE);
}
req->cmd = INIT_CMD_RUNLVL;
req->runlevel = argv[0][0];
req->sleeptime = shutdown_timeout;
}
}
|