]> granicus.if.org Git - linux-pam/blob - modules/register_static
Relevant BUGIDs: 416229
[linux-pam] / modules / register_static
1 #!/bin/sh
2
3 if [ `basename $PWD` != "modules" ]; then
4         echo "$0 must be run from the .../modules directory"
5         exit 1
6 fi
7
8 merge_line ()
9 {
10         if [ $# != 3 ]; then
11                 echo "usage: merge_line token filename 'new line'"
12         fi
13         if [ -f $2 ]; then
14 # remove any existing entry...
15                 grep -v "$1" $2 > tmp.$2
16                 rm -f $2
17                 mv {tmp.,}$2
18         fi
19         cat << EOT >> $2
20 $3
21 EOT
22
23 }
24
25
26 if [ $# -ne 2 ]; then
27
28         cat << EOT 2>&1
29 $0:     this script takes TWO arguments:
30         the 'alphanumeric label' of the module and the location of
31         its object file from the .../modules/ directory
32 EOT
33         exit 1
34
35 else
36         echo "
37  *> registering static module: $1 ($2) <*
38 "
39         merge_line "$1" _static_module_list "\
40 extern struct pam_module _$1_modstruct;"
41
42         merge_line "$1" _static_module_entry "    &_$1_modstruct,"
43         if [ -n "$2" ]; then
44                 merge_line "$2" _static_module_objects "../modules/$2"
45         fi
46
47 fi
48
49 exit 0