[hackers] [sltar] initial checkin || gottox

From: <hg_AT_suckless.org>
Date: Sun, 11 Nov 2012 17:23:38 +0100 (CET)

changeset: 0:d3c9b960c288
user: gottox_AT_rootkit.lan
date: Wed Dec 19 00:16:32 2007 +0100
files: Makefile config.mk tar.c
description:
initial checkin


diff -r 000000000000 -r d3c9b960c288 Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile Wed Dec 19 00:16:32 2007 +0100
_AT_@ -0,0 +1,57 @@
+# tar - a minimal implementation of tar
+# (c) 2007 Enno Boland
+
+include config.mk
+
+SRC = tar.c
+OBJ = ${SRC:.c=.o}
+TARGET = tar
+
+all: options ${TARGET}
+
+options:
+ _AT_echo spiceman build options:
+ _AT_echo "CFLAGS = ${CFLAGS}"
+ _AT_echo "LDFLAGS = ${LDFLAGS}"
+ _AT_echo "CC = ${CC}"
+
+${OBJ}: config.mk
+
+%.o: %.c
+ _AT_echo CC $@
+ _AT_${CC} -c ${CFLAGS} $<
+
+${TARGET}: ${OBJ}
+ _AT_echo CC -o $@
+ _AT_${CC} -o $@ ${OBJ} ${LDFLAGS}
+
+clean:
+ _AT_echo cleaning
+ _AT_rm -f -- ${OBJ} ${TARGET} ${TARGET}-${VERSION}.tar.gz
+
+dist: clean
+ _AT_echo creating dist tarball
+ _AT_mkdir -p ${TARGET}-${VERSION}
+ _AT_cp -R LICENSE Makefile \
+ ${TARGET}.1 ${SRC} ${TARGET}-${VERSION}
+ _AT_tar -cf ${TARGET}-${VERSION}.tar ${TARGET}-${VERSION}
+ _AT_gzip ${TARGET}-${VERSION}.tar
+ _AT_rm -rf ${TARGET}-${VERSION}
+
+install: all
+ _AT_echo installing executable file to ${DESTDIR}${PREFIX}/bin
+ _AT_mkdir -p ${DESTDIR}${PREFIX}/bin
+ _AT_cp -f spiceman ${DESTDIR}${PREFIX}/bin
+ _AT_chmod 755 ${DESTDIR}${PREFIX}/bin/spiceman
+ _AT_echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
+ _AT_mkdir -p ${DESTDIR}${MANPREFIX}/man1
+ _AT_sed "s/VERSION/${VERSION}/g" < spiceman.1 > ${DESTDIR}${MANPREFIX}/man1/spiceman.1
+ _AT_chmod 644 ${DESTDIR}${MANPREFIX}/man1/spiceman.1
+
+uninstall:
+ _AT_echo removing executable file from ${DESTDIR}${PREFIX}/bin
+ _AT_rm -f ${DESTDIR}${PREFIX}/bin/spiceman
+ _AT_echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
+ _AT_rm -f ${DESTDIR}${MANPREFIX}/man1/spiceman.1
+
+.PHONY: all options clean dist install uninstall
diff -r 000000000000 -r d3c9b960c288 config.mk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/config.mk Wed Dec 19 00:16:32 2007 +0100
_AT_@ -0,0 +1,19 @@
+# tar version
+VERSION = 0.0
+
+# Customize below to fit your system
+
+# paths
+PREFIX = /usr/local
+MANPREFIX = ${PREFIX}/share/man
+
+# includes and libs
+INCS = -I. -I/usr/include
+LIBS = -L/usr/lib -lc
+
+# flags
+CFLAGS = -static -Os -g -Wall -Werror ${INCS} -DVERSION=\"${VERSION}\"
+LDFLAGS = -g ${LIBS}
+
+# compiler and linker
+CC = cc
diff -r 000000000000 -r d3c9b960c288 tar.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tar.c Wed Dec 19 00:16:32 2007 +0100
_AT_@ -0,0 +1,57 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+
+#define USAGE { puts("tar [xt]"); exit(EXIT_FAILURE); }
+#define FORBLOCK(x,b) for(l = x; l > 0 && (n = read(0,(void *)(b),512)) > 0; l -= n)
+
+/* POSIX tar Header Block, from POSIX 1003.1-1990 */
+struct Header
+{
+ /* Header: 512 Byte */
+ char name[100]; /* 0-99 */
+ char mode[8]; /* 100-107 */
+ char uid[8]; /* 108-115 */
+ char gid[8]; /* 116-123 */
+ char size[12]; /* 124-135 */
+ char mtime[12]; /* 136-147 */
+ char chksum[8]; /* 148-155 */
+ char typeflag; /* 156-156 */
+ char linkname[100]; /* 157-256 */
+ char magic[6]; /* 257-262 */
+ char version[2]; /* 263-264 */
+ char uname[32]; /* 265-296 */
+ char gname[32]; /* 297-328 */
+ char devmajor[8]; /* 329-336 */
+ char devminor[8]; /* 337-344 */
+ char prefix[155]; /* 345-499 */
+ char padding[12]; /* 500-512 */
+};
+
+int main(int argc, char *argv[]) {
+ int a, l, n;
+ char b[512];
+ struct Header h;
+
+ if((argc != 2 || (a = argv[1][0]) == '\0') ||
+ argv[1][1] != '\0' || (a != 't' && a != 'x'))
+ USAGE;
+ while(1) {
+ FORBLOCK(sizeof(h),&h);
+ if(*h.name == '\0')
+ break;
+ else if(l != 0) {
+ fputs("Garbage!\n",stderr);
+ return EXIT_FAILURE;
+ }
+ if(a == 't') {
+ puts(h.name);
+ FORBLOCK(strtoull(h.size,0,8),b);
+ }
+ else {
+ FORBLOCK(strtoull(h.size,0,8),b)
+ puts("open, write, close, chmod, chown");
+ }
+ }
+ return EXIT_SUCCESS;
+}
Received on Sun Nov 11 2012 - 17:23:38 CET

This archive was generated by hypermail 2.3.0 : Sun Nov 11 2012 - 17:24:14 CET