Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalware-current.git;a=commitdiff;h=6e822275814008c65474c7c8c5e95ea34fa1eb7e
commit 6e822275814008c65474c7c8c5e95ea34fa1eb7e Author: James Buren <[email protected]> Date: Wed Dec 11 08:07:49 2013 -0600 fbterm-1.7.0-4-x86_64 * add login wrapper -- needed to clear UTMP records after login exits. * give full root to login process, but only under strict settings diff --git a/source/apps-extra/fbterm/FrugalBuild b/source/apps-extra/fbterm/FrugalBuild index bc0254c..196e6f1 100644 --- a/source/apps-extra/fbterm/FrugalBuild +++ b/source/apps-extra/fbterm/FrugalBuild @@ -17,6 +17,7 @@ source=(${source[@]} \ fbtermrc \ fbterm-daemon \ fbterm.service \ + fbterm-login.c \ login-seteuid.patch) sha1sums=('dc7b7ff29212c1551f35bf7a50967454d3b8c67c' \ '0da2be0f941a1e344f4a2653387a67f38f70281e' \ @@ -25,12 +26,14 @@ sha1sums=('dc7b7ff29212c1551f35bf7a50967454d3b8c67c' \ 'cd0030fc3acf1209068fc738e116f86717054e27' \ 'cac35d8ead091157395f3c51263208f91cef42ea' \ '85d75cf92a6e53f2045ff2b95b54c88b28101810' \ - 'd0127aeee28ee1be05a13beadb801d125cd5063c') + 'd64fcf93bc6a7d8c07e735c0b6003bf4a7397a4f' \ + '8c3620da414b657376ee7538920f07e34c1d7367') build() { Fbuild TERMINFO=$Fdestdir/usr/share/terminfo tic terminfo/$pkgname || Fdie + Fexec cc -Wall -Wextra -lutil $CFLAGS $Fsrcdir/fbterm-login.c -o $Fdestdir/usr/bin/fbterm-login || Fdie Ffile /etc/fbtermrc Fmkdir /var/lib/fbterm Fln /etc/fbtermrc /var/lib/fbterm/.fbtermrc diff --git a/source/apps-extra/fbterm/fbterm-login.c b/source/apps-extra/fbterm/fbterm-login.c new file mode 100644 index 0000000..52ca269 --- /dev/null +++ b/source/apps-extra/fbterm/fbterm-login.c @@ -0,0 +1,52 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> +#include <utmp.h> + +extern int main(void) +{ + pid_t pid = -1; + int status = 0; + char tty[128] = {0}; + + if(getuid() != 0 || geteuid() != 0) + { + puts("Must be run as root."); + return EXIT_FAILURE; + } + + if(!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO) || !isatty(STDERR_FILENO)) + { + puts("Must be connected to a TTY."); + return EXIT_FAILURE; + } + + if(ttyname_r(STDIN_FILENO,tty,sizeof(tty)) != 0) + { + puts("Cannot find the TTY device."); + return EXIT_FAILURE; + } + + if((pid = fork()) == -1) + { + puts("Failed to fork."); + return EXIT_FAILURE; + } + + if(pid == 0) + { + execl("/bin/login","/bin/login",(void *) 0); + _exit(EXIT_FAILURE); + } + + waitpid(pid,&status,0); + + if(strncmp(tty,"/dev/",5) == 0) + logout(tty+5); + else + logout(tty); + + return EXIT_SUCCESS; +} diff --git a/source/apps-extra/fbterm/login-seteuid.patch b/source/apps-extra/fbterm/login-seteuid.patch index e2bf15b..5daed84 100644 --- a/source/apps-extra/fbterm/login-seteuid.patch +++ b/source/apps-extra/fbterm/login-seteuid.patch @@ -1,6 +1,6 @@ diff -ur a/src/lib/shell.cpp b/src/lib/shell.cpp ---- a/src/lib/shell.cpp 2010-10-05 23:23:08.000000000 -0500 -+++ b/src/lib/shell.cpp 2013-11-21 19:18:54.221684798 -0600 +--- a/src/lib/shell.cpp 2013-11-21 22:33:22.217250976 -0600 ++++ b/src/lib/shell.cpp 2013-12-11 08:04:55.271940460 -0600 @@ -32,6 +32,9 @@ #include <sys/wait.h> #include "shell.h" @@ -11,27 +11,39 @@ diff -ur a/src/lib/shell.cpp b/src/lib/shell.cpp void waitChildProcessExit(s32 pid) { if (pid < 0) return; -@@ -81,6 +84,15 @@ +@@ -71,6 +74,7 @@ + void Shell::createShellProcess(s8 **command) + { + s32 fd; ++ uid_t uid = getuid(); + mPid = forkpty(&fd, NULL, NULL, NULL); + + switch (mPid) { +@@ -81,6 +85,18 @@ initShellProcess(); setenv("TERM", "linux", 1); + if( -+ getuid() == FBTERM_UID && -+ getgid() == FBTERM_GID && -+ command != 0 && -+ command[0] != 0 && -+ strcmp(command[0],"/bin/login") == 0 ++ getuid() == FBTERM_UID && ++ getgid() == FBTERM_GID && ++ command != 0 && ++ command[0] != 0 && ++ strcmp(command[0],"/usr/bin/fbterm-login") == 0 + ) ++ { + seteuid(0); ++ setuid(0); ++ } + if (command) { execvp(command[0], command); } else { -@@ -93,6 +105,8 @@ +@@ -93,6 +109,9 @@ execlp("/bin/sh", "/bin/sh", NULL); } -+ seteuid(getuid()); ++ setuid(uid); ++ seteuid(uid); + exit(1); break; _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
