summaryrefslogtreecommitdiffstats
path: root/sudoers/sudoers.xslt
blob: f33fc10651a89e08e8e5189d707ac442b75fb9c3 (plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:md="http://freeipa.org/xsl/metadata/1.0"
  xmlns:sudoers="http://freeipa.org/xml/rng/sudo/sudoers/1.0">

  <md:output_file name="/etc/sudoers" owner="root" group="root" permission="440"/>

  <xsl:output method="text" indent="no"/>
  <xsl:strip-space elements="*"/>

  <xsl:template match="/">
    <xsl:text># IPA generated /etc/sudoers: DO NOT EDIT&#xA;&#xA;</xsl:text>
    <xsl:apply-templates select="sudoers:ipa"/>
  </xsl:template>

  <xsl:template match="sudoers:ipa">
    <xsl:apply-templates>
      <xsl:with-param name="sudoers:ipaconfig"/>
    </xsl:apply-templates>
  </xsl:template>

  <xsl:template match="sudoers:ipaconfig">
    <xsl:apply-templates>
      <xsl:with-param name="sudoers:sudoers" select="''"/>
    </xsl:apply-templates>
  </xsl:template>


  <xsl:template match="sudoers:metadata">
  </xsl:template>

  <xsl:template match="sudoers:sudoers">

    <xsl:variable name="name">
      <xsl:apply-templates select="sudoers:subject">
      </xsl:apply-templates>
    </xsl:variable>

    <xsl:apply-templates>
    <!-- <xsl:apply-templates select="sudoers:command"> -->
      <xsl:with-param name="name" select="$name"/>
    </xsl:apply-templates>
  </xsl:template>



  <xsl:template match="sudoers:subject">
    <xsl:call-template name="format_name">
      <xsl:with-param name="name" select="sudoers:name"/>
      <xsl:with-param name="type" select="sudoers:type"/>
    </xsl:call-template>
  </xsl:template>

  <xsl:template match="sudoers:option">
    <xsl:text># found an option &#xA;&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="sudoers:command">
    <xsl:param name="name"/>
    <xsl:variable name="command" select="sudoers:path"/>
    <xsl:variable name="runas" select="sudoers:runas"/>
    <xsl:variable name="tag">
      <xsl:call-template name="format_tag">
        <xsl:with-param name="tag" select="sudoers:tag"/>
      </xsl:call-template>
    </xsl:variable>

    <xsl:value-of select="$name"/>
    <xsl:text>=</xsl:text>
    <xsl:if test="$runas != ''">
      <xsl:text>(</xsl:text>
      <xsl:value-of select="$runas"/>
      <xsl:text>)</xsl:text>
    </xsl:if>
    <xsl:text> </xsl:text>
    <xsl:value-of select="$tag"/>
    <xsl:text> </xsl:text>
    <xsl:value-of select="$command"/>
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template name="format_name">
    <xsl:param name="name"/>
    <xsl:param name="type"/>

    <xsl:choose>
      <xsl:when test="$type = 'netgroup'">
        <xsl:text>+</xsl:text>
      </xsl:when>
      <xsl:when test="$type = 'posixGroup'">
        <xsl:text>%</xsl:text>
      </xsl:when>
    </xsl:choose>
    <xsl:value-of select="$name"/>
  </xsl:template>

  <xsl:template name="format_tag">
    <xsl:param name="tag"/>

    <xsl:if test="$tag != ''">
      <xsl:value-of select="$tag"/>
      <xsl:text>:</xsl:text>
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>