Last active
July 22, 2018 22:23
-
-
Save zmwangx/f70e6bcae5a533fef8d5f74d3b6b9cdc to your computer and use it in GitHub Desktop.
Trivial program to reload apache without root
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/a2graceful |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
int main() { | |
if (setuid(0) != 0) { | |
perror("setuid"); | |
exit(1); | |
}; | |
execl("/usr/sbin/service", "/usr/sbin/service", "apache2", "graceful", NULL); | |
perror("execl"); | |
exit(1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PREFIX ?= /usr/local | |
CFLAGS += -Wall -Wextra | |
BINDIR = $(DESTDIR)$(PREFIX)/bin | |
.PHONY: all install clean distclean | |
all: a2graceful | |
a2graceful: a2graceful.o | |
$(LINK.c) $^ -o $@ | |
install: a2graceful | |
install -m 4755 a2graceful $(BINDIR) | |
clean: | |
@- $(RM) a2graceful.o a2graceful | |
distclean: clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment