new NOFORKs: pwdx,kill[all5],ttysize,realpath,readlink NOEXECs: date,resize
function old new delta run_nofork_applet 258 280 +22 readlink_main 112 123 +11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 33/0) Total: 33 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
@@ -58,7 +58,7 @@
|
||||
//config: the same format. With it on, 'date DATE' additionally supports
|
||||
//config: MMDDhhmm[[YY]YY][.ss] format.
|
||||
|
||||
//applet:IF_DATE(APPLET(date, BB_DIR_BIN, BB_SUID_DROP))
|
||||
//applet:IF_DATE(APPLET_NOEXEC(date, date, BB_DIR_BIN, BB_SUID_DROP, date))
|
||||
|
||||
//kbuild:lib-$(CONFIG_DATE) += date.o
|
||||
|
||||
@@ -152,12 +152,6 @@ enum {
|
||||
OPT_HINT = (1 << 6) * ENABLE_FEATURE_DATE_ISOFMT, /* D */
|
||||
};
|
||||
|
||||
static void maybe_set_utc(int opt)
|
||||
{
|
||||
if (opt & OPT_UTC)
|
||||
putenv((char*)"TZ=UTC0");
|
||||
}
|
||||
|
||||
#if ENABLE_LONG_OPTS
|
||||
static const char date_longopts[] ALIGN1 =
|
||||
"rfc-822\0" No_argument "R"
|
||||
@@ -170,6 +164,19 @@ static const char date_longopts[] ALIGN1 =
|
||||
;
|
||||
#endif
|
||||
|
||||
/* We are a NOEXEC applet.
|
||||
* Obstacles to NOFORK:
|
||||
* - we change env
|
||||
* - xasprintf result not freed
|
||||
* - after xasprintf we use other xfuncs
|
||||
*/
|
||||
|
||||
static void maybe_set_utc(int opt)
|
||||
{
|
||||
if (opt & OPT_UTC)
|
||||
putenv((char*)"TZ=UTC0");
|
||||
}
|
||||
|
||||
int date_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
|
@@ -20,7 +20,7 @@
|
||||
//config: help
|
||||
//config: Enable the readlink option (-f).
|
||||
|
||||
//applet:IF_READLINK(APPLET(readlink, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
//applet:IF_READLINK(APPLET_NOFORK(readlink, readlink, BB_DIR_USR_BIN, BB_SUID_DROP, readlink))
|
||||
|
||||
//kbuild:lib-$(CONFIG_READLINK) += readlink.o
|
||||
|
||||
@@ -85,6 +85,7 @@ int readlink_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (!(opt & 4)) /* not -v */
|
||||
logmode = LOGMODE_NONE;
|
||||
|
||||
/* NOFORK: only one alloc is allowed; must free */
|
||||
if (opt & 1) { /* -f */
|
||||
buf = xmalloc_realpath(fname);
|
||||
} else {
|
||||
@@ -94,9 +95,7 @@ int readlink_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (!buf)
|
||||
return EXIT_FAILURE;
|
||||
printf((opt & 2) ? "%s" : "%s\n", buf);
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(buf);
|
||||
free(buf);
|
||||
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@
|
||||
//config: Return the canonicalized absolute pathname.
|
||||
//config: This isn't provided by GNU shellutils, but where else does it belong.
|
||||
|
||||
//applet:IF_REALPATH(APPLET(realpath, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
//applet:IF_REALPATH(APPLET_NOFORK(realpath, realpath, BB_DIR_USR_BIN, BB_SUID_DROP, realpath))
|
||||
|
||||
//kbuild:lib-$(CONFIG_REALPATH) += realpath.o
|
||||
|
||||
@@ -36,6 +36,7 @@ int realpath_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
|
||||
do {
|
||||
/* NOFORK: only one alloc is allowed; must free */
|
||||
char *resolved_path = xmalloc_realpath(*argv);
|
||||
if (resolved_path != NULL) {
|
||||
puts(resolved_path);
|
||||
|
Reference in New Issue
Block a user