mirror of https://github.com/postgres/postgres
parent
a959e3f7c0
commit
13f8875017
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,33 @@ |
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile
|
||||
# Makefile for bin/pg_id
|
||||
#
|
||||
# Copyright (C) 2000 by PostgreSQL Global Development Team
|
||||
#
|
||||
# $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/Makefile,v 1.14 2000/01/20 21:51:07 petere Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
SRCDIR= ../..
|
||||
include ../../Makefile.global |
||||
|
||||
OBJS= pg_id.o
|
||||
|
||||
all: pg_id |
||||
|
||||
pg_id: $(OBJS) |
||||
$(CC) -o pg_id $(OBJS) $(LDFLAGS)
|
||||
|
||||
install: pg_id |
||||
$(INSTALL) $(INSTL_EXE_OPTS) pg_id$(X) $(BINDIR)/pg_id
|
||||
|
||||
depend dep: |
||||
$(CC) -MM $(CFLAGS) *.c >depend
|
||||
|
||||
clean: |
||||
rm -f pg_id $(OBJS)
|
||||
|
||||
ifeq (depend,$(wildcard depend)) |
||||
include depend |
||||
endif |
||||
@ -0,0 +1,91 @@ |
||||
/*
|
||||
* pg_id.c |
||||
* |
||||
* A crippled id utility for use in various shell scripts in use by PostgreSQL |
||||
* (in particular initdb) |
||||
* |
||||
* Copyright (C) 2000 by PostgreSQL Global Development Group |
||||
* |
||||
* $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.11 2000/01/20 21:51:07 petere Exp $ |
||||
*/ |
||||
#include <c.h> |
||||
|
||||
#include <pwd.h> |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
#include <unistd.h> |
||||
#include <sys/types.h> |
||||
|
||||
int main(int argc, char * argv[]) |
||||
{ |
||||
int c; |
||||
int nameflag = 0, |
||||
realflag = 0, |
||||
userflag = 0; |
||||
const char * username = NULL; |
||||
|
||||
struct passwd * pw; |
||||
|
||||
while ((c = getopt(argc, argv, "nru")) != -1) |
||||
{ |
||||
switch(c) |
||||
{ |
||||
case 'n': |
||||
nameflag = 1; |
||||
break; |
||||
case 'r': |
||||
realflag = 1; |
||||
break; |
||||
case 'u': |
||||
userflag = 1; |
||||
break; |
||||
default: |
||||
fprintf(stderr, "Usage: %s [-n] [-r] [-u] [username]\n", argv[0]); |
||||
exit(1); |
||||
} |
||||
} |
||||
|
||||
if (argc - optind >= 1) |
||||
username = argv[optind]; |
||||
|
||||
if (nameflag && !userflag) |
||||
{ |
||||
fprintf(stderr, "%s: -n must be used together with -u\n", argv[0]); |
||||
exit(1); |
||||
} |
||||
if (username && realflag) |
||||
{ |
||||
fprintf(stderr, "%s: -r cannot be used when a user name is given\n", argv[0]); |
||||
exit(1); |
||||
} |
||||
|
||||
|
||||
if (username) |
||||
{ |
||||
pw = getpwnam(username); |
||||
if (!pw) |
||||
{ |
||||
fprintf(stderr, "%s: %s: no such user\n", argv[0], username); |
||||
exit(1); |
||||
} |
||||
} |
||||
else if (realflag) |
||||
pw = getpwuid(getuid()); |
||||
else |
||||
pw = getpwuid(geteuid()); |
||||
|
||||
if (!pw) |
||||
{ |
||||
perror(argv[0]); |
||||
exit(1); |
||||
} |
||||
|
||||
if (!userflag) |
||||
printf("uid=%d(%s)\n", (int)pw->pw_uid, pw->pw_name); |
||||
else if (nameflag) |
||||
puts(pw->pw_name); |
||||
else |
||||
printf("%d\n", (int)pw->pw_uid); |
||||
|
||||
return 0; |
||||
} |
||||
@ -0,0 +1,36 @@ |
||||
#! /bin/sh |
||||
# mkinstalldirs --- make directory hierarchy |
||||
# Author: Noah Friedman <friedman@prep.ai.mit.edu> |
||||
# Created: 1993-05-16 |
||||
# Last modified: 1994-03-25 |
||||
# Public domain |
||||
|
||||
errstatus=0 |
||||
|
||||
for file in ${1+"$@"} ; do |
||||
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` |
||||
shift |
||||
|
||||
pathcomp= |
||||
for d in ${1+"$@"} ; do |
||||
pathcomp="$pathcomp$d" |
||||
case "$pathcomp" in |
||||
-* ) pathcomp=./$pathcomp ;; |
||||
esac |
||||
|
||||
if test ! -d "$pathcomp"; then |
||||
echo "mkdir $pathcomp" 1>&2 |
||||
mkdir "$pathcomp" > /dev/null 2>&1 || lasterr=$? |
||||
fi |
||||
|
||||
if test ! -d "$pathcomp"; then |
||||
errstatus=$lasterr |
||||
fi |
||||
|
||||
pathcomp="$pathcomp/" |
||||
done |
||||
done |
||||
|
||||
exit $errstatus |
||||
|
||||
# mkinstalldirs ends here |
||||
Loading…
Reference in new issue