aboutsummaryrefslogtreecommitdiff
path: root/console-tools/loadfont.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-06 19:05:45 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-06 19:05:45 +0200
commit1b280e46520420dad1ed1e985d11b7b2bea493e4 (patch)
tree7214d60134270a4dc24287ce7b3c616fb3a9e8e6 /console-tools/loadfont.c
parent5cb907fffc25ce26d7388b485e64261f7ee42450 (diff)
downloadbusybox-w32-1b280e46520420dad1ed1e985d11b7b2bea493e4.tar.gz
busybox-w32-1b280e46520420dad1ed1e985d11b7b2bea493e4.tar.bz2
busybox-w32-1b280e46520420dad1ed1e985d11b7b2bea493e4.zip
loadfont,setfont: make them NOEXEC
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'console-tools/loadfont.c')
-rw-r--r--console-tools/loadfont.c54
1 files changed, 25 insertions, 29 deletions
diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c
index 6dc8fa831..623d98175 100644
--- a/console-tools/loadfont.c
+++ b/console-tools/loadfont.c
@@ -51,31 +51,12 @@
51//config: default y 51//config: default y
52//config: depends on LOADFONT || SETFONT 52//config: depends on LOADFONT || SETFONT
53 53
54//applet:IF_LOADFONT(APPLET(loadfont, BB_DIR_USR_SBIN, BB_SUID_DROP)) 54//applet:IF_LOADFONT(APPLET_NOEXEC(loadfont, loadfont, BB_DIR_USR_SBIN, BB_SUID_DROP, loadfont))
55//applet:IF_SETFONT(APPLET(setfont, BB_DIR_USR_SBIN, BB_SUID_DROP)) 55//applet:IF_SETFONT(APPLET_NOEXEC(setfont, setfont, BB_DIR_USR_SBIN, BB_SUID_DROP, setfont))
56 56
57//kbuild:lib-$(CONFIG_LOADFONT) += loadfont.o 57//kbuild:lib-$(CONFIG_LOADFONT) += loadfont.o
58//kbuild:lib-$(CONFIG_SETFONT) += loadfont.o 58//kbuild:lib-$(CONFIG_SETFONT) += loadfont.o
59 59
60//usage:#define loadfont_trivial_usage
61//usage: "< font"
62//usage:#define loadfont_full_usage "\n\n"
63//usage: "Load a console font from stdin"
64/* //usage: "\n -C TTY Affect TTY instead of /dev/tty" */
65//usage:
66//usage:#define loadfont_example_usage
67//usage: "$ loadfont < /etc/i18n/fontname\n"
68//usage:
69//usage:#define setfont_trivial_usage
70//usage: "FONT [-m MAPFILE] [-C TTY]"
71//usage:#define setfont_full_usage "\n\n"
72//usage: "Load a console font\n"
73//usage: "\n -m MAPFILE Load console screen map"
74//usage: "\n -C TTY Affect TTY instead of /dev/tty"
75//usage:
76//usage:#define setfont_example_usage
77//usage: "$ setfont -m koi8-r /etc/i18n/fontname\n"
78
79#include "libbb.h" 60#include "libbb.h"
80#include <sys/kd.h> 61#include <sys/kd.h>
81 62
@@ -352,6 +333,14 @@ static void do_load(int fd, unsigned char *buffer, size_t len)
352 333
353 334
354#if ENABLE_LOADFONT 335#if ENABLE_LOADFONT
336//usage:#define loadfont_trivial_usage
337//usage: "< font"
338//usage:#define loadfont_full_usage "\n\n"
339//usage: "Load a console font from stdin"
340/* //usage: "\n -C TTY Affect TTY instead of /dev/tty" */
341//usage:
342//usage:#define loadfont_example_usage
343//usage: "$ loadfont < /etc/i18n/fontname\n"
355int loadfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 344int loadfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
356int loadfont_main(int argc UNUSED_PARAM, char **argv) 345int loadfont_main(int argc UNUSED_PARAM, char **argv)
357{ 346{
@@ -380,11 +369,9 @@ int loadfont_main(int argc UNUSED_PARAM, char **argv)
380} 369}
381#endif 370#endif
382 371
383#if ENABLE_SETFONT
384
385/*
386kbd-1.12:
387 372
373#if ENABLE_SETFONT
374/* kbd-1.12:
388setfont [-O font+umap.orig] [-o font.orig] [-om cmap.orig] 375setfont [-O font+umap.orig] [-o font.orig] [-om cmap.orig]
389[-ou umap.orig] [-N] [font.new ...] [-m cmap] [-u umap] [-C console] 376[-ou umap.orig] [-N] [font.new ...] [-m cmap] [-u umap] [-C console]
390[-hNN] [-v] [-V] 377[-hNN] [-v] [-V]
@@ -414,8 +401,17 @@ setfont [-O font+umap.orig] [-o font.orig] [-om cmap.orig]
414-v Verbose 401-v Verbose
415-V Version 402-V Version
416*/ 403*/
404//usage:#define setfont_trivial_usage
405//usage: "FONT [-m MAPFILE] [-C TTY]"
406//usage:#define setfont_full_usage "\n\n"
407//usage: "Load a console font\n"
408//usage: "\n -m MAPFILE Load console screen map"
409//usage: "\n -C TTY Affect TTY instead of /dev/tty"
410//usage:
411//usage:#define setfont_example_usage
412//usage: "$ setfont -m koi8-r /etc/i18n/fontname\n"
417 413
418#if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP 414# if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
419static int ctoi(char *s) 415static int ctoi(char *s)
420{ 416{
421 if (s[0] == '\'' && s[1] != '\0' && s[2] == '\'' && s[3] == '\0') 417 if (s[0] == '\'' && s[1] != '\0' && s[2] == '\'' && s[3] == '\0')
@@ -429,7 +425,7 @@ static int ctoi(char *s)
429 return -1; 425 return -1;
430 return xstrtoul(s, 0); 426 return xstrtoul(s, 0);
431} 427}
432#endif 428# endif
433 429
434int setfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 430int setfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
435int setfont_main(int argc UNUSED_PARAM, char **argv) 431int setfont_main(int argc UNUSED_PARAM, char **argv)
@@ -480,7 +476,7 @@ int setfont_main(int argc UNUSED_PARAM, char **argv)
480 if (len == 2*E_TABSZ) 476 if (len == 2*E_TABSZ)
481 mode = PIO_UNISCRNMAP; 477 mode = PIO_UNISCRNMAP;
482 } 478 }
483#if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP 479# if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
484 // assume textual Unicode console maps: 480 // assume textual Unicode console maps:
485 // 0x00 U+0000 # NULL (NUL) 481 // 0x00 U+0000 # NULL (NUL)
486 // 0x01 U+0001 # START OF HEADING (SOH) 482 // 0x01 U+0001 # START OF HEADING (SOH)
@@ -527,7 +523,7 @@ int setfont_main(int argc UNUSED_PARAM, char **argv)
527 } 523 }
528#undef unicodes 524#undef unicodes
529 } 525 }
530#endif // ENABLE_FEATURE_SETFONT_TEXTUAL_MAP 526# endif // ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
531 527
532 // do set screen map 528 // do set screen map
533 xioctl(fd, mode, map); 529 xioctl(fd, mode, map);