Initial commit
commit
fbb6bdef5a
|
@ -0,0 +1,19 @@
|
|||
FROM debian
|
||||
|
||||
COPY hello.c /src/
|
||||
|
||||
RUN \
|
||||
export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt update \
|
||||
&& apt install -y gcc \
|
||||
&& ( \
|
||||
cd /src \
|
||||
&& gcc -Wall -o /usr/local/bin/hello hello.c \
|
||||
) \
|
||||
&& apt autoremove -y --purge gcc \
|
||||
&& rm -rf \
|
||||
/var/lib/apt/lists/* \
|
||||
/var/tmp/* \
|
||||
/tmp/*
|
||||
|
||||
CMD ["hello"]
|
|
@ -0,0 +1,19 @@
|
|||
FROM alpine
|
||||
|
||||
COPY hello.c /src/
|
||||
|
||||
RUN \
|
||||
export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apk add --no-cache --virtual .build-deps \
|
||||
gcc \
|
||||
musl-dev \
|
||||
&& ( \
|
||||
cd /src \
|
||||
&& gcc -Wall -o /usr/local/bin/hello hello.c \
|
||||
) \
|
||||
&& apk del --no-cache .build-deps \
|
||||
&& rm -rf \
|
||||
/var/tmp/* \
|
||||
/tmp/*
|
||||
|
||||
CMD ["hello"]
|
|
@ -0,0 +1,31 @@
|
|||
#define _GNU_SOURCE
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
extern char *program_invocation_name;
|
||||
extern char *program_invocation_short_name;
|
||||
|
||||
int main() {
|
||||
register struct passwd *pw;
|
||||
register uid_t uid;
|
||||
|
||||
printf("This is %s speaking.\n", program_invocation_name);
|
||||
|
||||
uid = geteuid();
|
||||
pw = getpwuid(uid);
|
||||
|
||||
if (pw)
|
||||
{
|
||||
printf("Hello, %s!\n", pw->pw_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("I don't know your name but your ID is %d!\n", (unsigned) uid);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
#define _GNU_SOURCE
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
extern char *program_invocation_name;
|
||||
extern char *program_invocation_short_name;
|
||||
|
||||
int main() {
|
||||
register struct passwd *pw;
|
||||
register uid_t uid;
|
||||
|
||||
printf("This is %s speaking.\n", program_invocation_name);
|
||||
|
||||
uid = geteuid();
|
||||
pw = getpwuid(uid);
|
||||
|
||||
if (pw)
|
||||
{
|
||||
printf("Hello, %s!\n", pw->pw_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("I don't know your name but your ID is %d!\n", (unsigned) uid);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue