aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-02-22 14:02:07 +0100
committerMattias Andrée <m@maandree.se>2026-02-22 14:02:07 +0100
commit65220abc14724130b559d35bb418c28e1133ec01 (patch)
tree56d0f6856018b6d5ff682ed7b77201fc44bb81a6
parentenable more warnings (diff)
downloadgot-diminished-65220abc14724130b559d35bb418c28e1133ec01.tar.gz
got-diminished-65220abc14724130b559d35bb418c28e1133ec01.tar.bz2
got-diminished-65220abc14724130b559d35bb418c28e1133ec01.tar.xz
m fixesHEADmaster
Signed-off-by: Mattias Andrée <m@maandree.se>
-rw-r--r--.gitignore2
-rw-r--r--COPYING2
-rw-r--r--DEPENDENCIES29
-rw-r--r--Makefile61
-rw-r--r--README1
-rw-r--r--src/got-diminished10
-rw-r--r--src/got-diminished-cerberus.c74
-rw-r--r--src/got-diminished-login.c72
-rw-r--r--src/got-diminished-ssh.c53
9 files changed, 136 insertions, 168 deletions
diff --git a/.gitignore b/.gitignore
index dea3675..fa2d384 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
-_/
/bin
/got-diminished
\#*\#
@@ -27,4 +26,3 @@ _/
*.out
*.gch
*.su
-
diff --git a/COPYING b/COPYING
index bf9f165..4f9fc5e 100644
--- a/COPYING
+++ b/COPYING
@@ -1,6 +1,6 @@
got-diminished – Extension for gates-of-tartaros to minimise memory usage after logging in
-Copyright © 2013, 2014 Mattias Andrée (maandree@member.fsf.org)
+Copyright © 2013, 2014 Mattias Andrée (m@maandree.se)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/DEPENDENCIES b/DEPENDENCIES
index 48c6242..ebc9c39 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -1,23 +1,20 @@
RUNTIME DEPENDENCIES:
-<package> <command> <reason>
-libc the C library
-util-linux login login is used for authorisation and login
-util-linux setsid used to start login in a new session
-openssh ssh (optional) used for SSH login
-coreutils stty used to restore the tty settings
-
-Extension for gates-of-tartaros, add it as a dependency if your
-package system does not support extension packages.
+ libc
+ login
+ setsid
+ ssh
+ stty
+Extension for gates-of-tartaros, add it as a dependency
+if your package system does not support extension packages.
BUILD DEPENDENCIES:
-<package> <command> <when>
-make make required
-sed sed required
-coreutils cp required
-coreutils install required
-gcc gcc required
-
+ make
+ sh
+ c99
+ sed
+ mkdir
+ cp
diff --git a/Makefile b/Makefile
index f23230f..5d3334e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,21 +1,15 @@
-PREFIX = /usr
-LIBEXEC = /libexec
-SYSCONF = /etc
-PKGNAME = got-diminished
-DATA = /share
+PREFIX = /usr
+LIBEXEC = /libexec
+SYSCONF = /etc
+PKGNAME = got-diminished
+DATA = /share
LICENSES = $(PREFIX)$(DATA)/licenses
-OPTIMISE = -Os
-WARN = -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs \
- -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations \
- -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wsign-conversion \
- -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow \
- -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wwrite-strings \
- -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wpacked \
- -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const \
- -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format \
- -Wnormalized=nfkc -Wconversion -fstrict-aliasing -fstrict-overflow -fipa-pure-const \
- -ftree-vrp -fstack-usage -funsafe-loop-optimizations
+CC = c99
+
+CPPFLAGS =
+CFLAGS = -Os
+LDFLAGS =
BINS = login ssh cerberus
_BINS = $(foreach B, $(BINS), bin/got-diminished-$(B))
@@ -23,40 +17,31 @@ _BINS = $(foreach B, $(BINS), bin/got-diminished-$(B))
# Use /sbin for LIBEXEC if you do not have /libexec in PREFIX
-
-.PHONY: all
all: got-diminished $(_BINS)
-
got-diminished: src/got-diminished
cp "$<" "$@"
sed -i "s:/usr/libexec/:$(PREFIX)$(LIBEXEC)/:g" "$@"
-
bin/%: src/%.c
@mkdir -p bin
- gcc $(OPTIMISE) $(WARN) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o "$@" "$<"
+ $(CC) -o "$@" "$<" $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
-
-.PHONY: install
install: got-diminished $(_BINS)
- install -d -- "$(DESTDIR)$(SYSCONF)/gotrc.examples"
- install -m644 -- got-diminished "$(DESTDIR)$(SYSCONF)/gotrc.examples"
- install -d -- "$(DESTDIR)$(PREFIX)$(LIBEXEC)"
- install -m755 -- $(_BINS) "$(DESTDIR)$(PREFIX)$(LIBEXEC)"
- install -d -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)"
- install -m644 -- COPYING LICENSE "$(DESTDIR)$(LICENSES)/$(PKGNAME)"
-
+ mkdir -p -- "$(DESTDIR)$(SYSCONF)/gotrc.examples/"
+ mkdir -p -- "$(DESTDIR)$(PREFIX)$(LIBEXEC)/"
+ mkdir -p -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)/"
+ cp -- got-diminished "$(DESTDIR)$(SYSCONF)/gotrc.examples/"
+ cp -- $(_BINS) "$(DESTDIR)$(PREFIX)$(LIBEXEC)/"
+ cp -- COPYING LICENSE "$(DESTDIR)$(LICENSES)/$(PKGNAME)/"
-.PHONY: uninstall
uninstall:
- -rm -- $(foreach B, $(BINS), "$(DESTDIR)$(PREFIX)$(LIBEXEC)/got-diminished-$(B)")
- -rm -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)/COPYING"
- -rm -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)/LICENSE"
- -rm -d -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)"
-
+ -rm -- $(foreach B, $(BINS), "$(DESTDIR)$(PREFIX)$(LIBEXEC)/got-diminished-$(B)")
+ -rm -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)/COPYING"
+ -rm -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)/LICENSE"
+ -rmdir -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)"
-.PHONY: clean
clean:
- -rm -r bin got-diminished
+ -rm -rf -- bin got-diminished
+.PHONY: all install uninstall clean
diff --git a/README b/README
index 2979fd5..f0ce444 100644
--- a/README
+++ b/README
@@ -1,2 +1 @@
Extension for gates-of-tartaros to minimise memory usage after logging in
-
diff --git a/src/got-diminished b/src/got-diminished
index 618f63b..b675c49 100644
--- a/src/got-diminished
+++ b/src/got-diminished
@@ -1,10 +1,9 @@
# -*- shell-script -*-
-# This module minimising memory usage, when when you are entering
-# your passphrase in and is logged in, of gates-of-tartaros, by
-# replacing the gates-of-tartaros process with a smaller C program
-# that does not have anything for before you have entered your
-# username.
+# This module minimises memory usage while you are entering your
+# passphrase and logging in to gates-of-tartaros, by replacing the
+# gates-of-tartaros process with a smaller C program that does not do
+# anything before you have entered your username.
_use_ssh ()
@@ -17,4 +16,3 @@ _use_login ()
exec "/usr/libexec/got-diminished-login" "${user}" "${tty_settings}"
# exec "/usr/libexec/got-diminished-cerberus" "${user}" "${tty_settings}"
}
-
diff --git a/src/got-diminished-cerberus.c b/src/got-diminished-cerberus.c
index 8237c69..7f10d29 100644
--- a/src/got-diminished-cerberus.c
+++ b/src/got-diminished-cerberus.c
@@ -1,7 +1,7 @@
/**
* got-diminished – Extension for gates-of-tartaros to minimise memory usage after logging in
*
- * Copyright © 2013, 2014 Mattias Andrée (maandree@member.fsf.org)
+ * Copyright © 2013, 2014 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,43 +22,39 @@
#include <stdio.h>
-int main(int argc, char** argv)
+int
+main(int argc, char *argv[])
{
- pid_t pid = vfork();
- if (pid == -1)
- {
- perror("vfork");
- return 1;
- }
-
- if (pid)
- {
- waitpid(pid, &pid, 0);
- {
- size_t n = 0, i;
- char* stty = *(argv + 2);
- char* stty_cmd;
-
- while (*(stty + n++))
- ;
-
- stty_cmd = malloc((5 + n) * sizeof(char));
- for (i = 0; i < 5; i++)
- *(stty_cmd + i) = *("stty " + i);
- stty_cmd += 5;
- for (i = 0; i < n; i++)
- *(stty_cmd + i) = *(stty + i);
- stty_cmd -= 5;
-
- system(stty_cmd);
- free(stty_cmd);
- }
- }
- else
- execlp("setsid", "setsid", "-c", "cerberus", "--", *(argv + 1), NULL);
-
- return 0;
-
- (void) argc;
-}
+ pid_t pid = vfork();
+ if (pid == -1) {
+ perror("vfork");
+ return 1;
+ }
+
+ if (pid) {
+ size_t n = 0, i;
+ char *stty = argv[2];
+ char *stty_cmd;
+
+ waitpid(pid, &pid, 0);
+
+ while (stty[n++]);
+ stty_cmd = malloc((5 + n) * sizeof(char));
+ for (i = 0; i < 5; i++)
+ stty_cmd[i] = "stty "[i];
+ stty_cmd += 5;
+ for (i = 0; i < n; i++)
+ stty_cmd[i] = stty[i];
+ stty_cmd -= 5;
+
+ system(stty_cmd);
+ free(stty_cmd);
+ } else {
+ execlp("setsid", "setsid", "-c", "cerberus", "--", *(argv + 1), NULL);
+ }
+
+ return 0;
+
+ (void) argc;
+}
diff --git a/src/got-diminished-login.c b/src/got-diminished-login.c
index 28c70fd..e4df8f2 100644
--- a/src/got-diminished-login.c
+++ b/src/got-diminished-login.c
@@ -1,7 +1,7 @@
/**
* got-diminished – Extension for gates-of-tartaros to minimise memory usage after logging in
*
- * Copyright © 2013, 2014 Mattias Andrée (maandree@member.fsf.org)
+ * Copyright © 2013, 2014 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,43 +22,39 @@
#include <stdio.h>
-int main(int argc, char** argv)
+int
+main(int argc, char *argv[])
{
- pid_t pid = vfork();
- if (pid == -1)
- {
- perror("vfork");
- return 1;
- }
-
- if (pid)
- {
- waitpid(pid, &pid, 0);
- {
- size_t n = 0, i;
- char* stty = *(argv + 2);
- char* stty_cmd;
-
- while (*(stty + n++))
- ;
-
- stty_cmd = malloc((5 + n) * sizeof(char));
- for (i = 0; i < 5; i++)
- *(stty_cmd + i) = *("stty " + i);
- stty_cmd += 5;
- for (i = 0; i < n; i++)
- *(stty_cmd + i) = *(stty + i);
- stty_cmd -= 5;
+ pid_t pid = vfork();
+ if (pid == -1) {
+ perror("vfork");
+ return 1;
+ }
+
+ if (pid) {
+ size_t n = 0, i;
+ char *stty = argv[2];
+ char *stty_cmd;
+
+ waitpid(pid, &pid, 0);
- system(stty_cmd);
- free(stty_cmd);
- }
- }
- else
- execlp("setsid", "setsid", "-c", "login", "--", *(argv + 1), NULL);
-
- return 0;
-
- (void) argc;
-}
+ while (stty[n++]);
+ stty_cmd = malloc((5 + n) * sizeof(char));
+ for (i = 0; i < 5; i++)
+ stty_cmd[i] = "stty "[i];
+ stty_cmd += 5;
+ for (i = 0; i < n; i++)
+ stty_cmd[i] = stty[i];
+ stty_cmd -= 5;
+
+ system(stty_cmd);
+ free(stty_cmd);
+ } else {
+ execlp("setsid", "setsid", "-c", "login", "--", *(argv + 1), NULL);
+ }
+
+ return 0;
+
+ (void) argc;
+}
diff --git a/src/got-diminished-ssh.c b/src/got-diminished-ssh.c
index df74738..788917f 100644
--- a/src/got-diminished-ssh.c
+++ b/src/got-diminished-ssh.c
@@ -1,7 +1,7 @@
/**
* got-diminished – Extension for gates-of-tartaros to minimise memory usage after logging in
*
- * Copyright © 2013, 2014 Mattias Andrée (maandree@member.fsf.org)
+ * Copyright © 2013, 2014 Mattias Andrée (m@maandree.se)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,31 +20,30 @@
#include <unistd.h>
-int main(int argc, char** argv)
+int
+main(int argc, char *argv[])
{
- size_t n = 0, i;
- char* user = *(argv + 1);
- char* command;
-
- while (*(user + n++))
- ;
-
- command = malloc((14 + n) * sizeof(char));
- for (i = 0; i < 14; i++)
- *(command + i) = *("setsid -c ssh " + i);
- command += 14;
- for (i = 0; i < n; i++)
- *(command + i) = *(user + i);
- command -= 14;
-
- if (system(command))
- sleep(3);
- free(command);
-
- execlp("stty", "stty", *(argv + 2), NULL);
-
- return 0;
-
- (void) argc;
-}
+ size_t n = 0, i;
+ char *user = argv[1];
+ char *command;
+
+ while (user[n++]);
+
+ command = malloc((14 + n) * sizeof(char));
+ for (i = 0; i < 14; i++)
+ *(command + i) = "setsid -c ssh "[i];
+ command += 14;
+ for (i = 0; i < n; i++)
+ command[i] = user[i];
+ command -= 14;
+
+ if (system(command))
+ sleep(3);
+ free(command);
+ execlp("stty", "stty", argv[2], NULL);
+
+ return 0;
+
+ (void) argc;
+}