File: ac_check_user.m4

package info (click to toggle)
autoconf-archive 20060312-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,180 kB
  • ctags: 13
  • sloc: sh: 455; makefile: 44
file content (37 lines) | stat: -rw-r--r-- 992 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
dnl @synopsis AC_CHECK_USER
dnl
dnl Check if the specified UNIX user exists, if yes set your
dnl environment variable to that username else unset your environment
dnl variable
dnl
dnl Example:
dnl
dnl     AC_CHECK_USER(USER, [gleensalmon])
dnl     if test x$USER = xgleensalmon; then
dnl         bla..bla..bla..
dnl     else
dnl         bla..bla..bla..
dnl     fi
dnl
dnl Besides checking existence, this macro also set these environment
dnl variables upon completion:
dnl
dnl     USER_HOME = home directory of user, written in /etc/passwd
dnl
dnl @category Misc
dnl @author Gleen Salmon <gleensalmon@yahoo.com>
dnl @version 2002-04-11
dnl @license GPLWithACException

AC_DEFUN([AC_CHECK_USER],[
AC_MSG_CHECKING([for user $2])
if grep ^$2: /etc/passwd > /dev/null; then
        $1=$2
        USER_HOME=`grep ^$2: /etc/passwd | sed "s/^\([[^:]]*:\)\{5\}\([[^:]]*\):[[^:]]*$/\2/"`
        AC_MSG_RESULT([yes])
else
        unset $1
        unset USER_HOME
        AC_MSG_RESULT([no])
fi;dnl
])