-
Notifications
You must be signed in to change notification settings - Fork 5
/
ad.mk
38 lines (36 loc) · 1.01 KB
/
ad.mk
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
38
# ad.mk
#
# AD and LDAP make-functions
#
#
# chars
#
char_null :=
char_space := $(char_null) #
char_comma := ,
char_dot := .
char_colon := :
#
# $(call ad_sub_dc,example.com) -> dc=example,dc=com
#
ad_sub_dc = $(subst $(char_space),$(char_comma),$(addprefix dc=, $(subst ., ,$(1))))
#
# $(call ad_sub_dot,dc=example,dc=com) -> example.com
#
ad_sub_dot = $(subst $(char_comma)dc=,$(char_dot),$(patsubst dc=%,%,$(1)))
#
# $(call ad_cat_dn,admin,dc=example,dc=com) -> cn=admin,dc=example,dc=com
#
ad_cat_dn = cn=$(1),$(2)
#
# $(call ad_cut_dot,1,1,example.com) -> example
#
ad_cut_dot = $(subst $(char_space),$(char_dot),$(wordlist $(1), $(2), $(subst $(char_dot),$(char_space),$(3))))
#
# $(call ad_rootdc,2,9,adm.dom.org:secret) -> dom.org
#
ad_rootdc = $(subst $(char_space),$(char_dot),$(wordlist $(1), $(2), $(subst $(char_dot),$(char_space),$(firstword $(subst $(char_colon),$(char_space),$(3))))))
#
# $(call ad_rootpw,adm.dom.org:secret) -> secret
#
ad_rootpw = $(lastword $(subst $(char_colon),$(char_space),$(1)))