<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><br>
    </p>
    <div class="moz-cite-prefix">Le 06/04/2019 à 18:32, Patrick Perrier
      a écrit :<br>
    </div>
    <blockquote type="cite"
      cite="mid:df4b0646-78dc-c23b-3dae-46e7281b7d9f@free.fr">Bonjour,
      <br>
      <br>
      J'essaie de faire un paquet pour créer un utilisateur avec la
      fonction create_user.
      <br>
      <br>
      Mon paquet fonctionne si l'utilisateur n'existe pas sur la
      machine, mais sinon, j'ai une erreur. Existe t-il une fonction
      pour tester si un compte existe ?
      <br>
    </blockquote>
    <p><br>
    </p>
    <p>J'utilise un simple run pour ça:</p>
    <p><br>
    </p>
    <p><span style="color: rgb(51, 51, 51); font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">    run(</span><span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">r'net user dani /add'</span><span style="color: rgb(51, 51, 51); font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">, accept_returncodes=[</span><span class="hljs-number" style="box-sizing: inherit; color: rgb(0, 128, 128); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">0</span><span style="color: rgb(51, 51, 51); font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">,</span><span class="hljs-number" style="box-sizing: inherit; color: rgb(0, 128, 128); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">2</span><span style="color: rgb(51, 51, 51); font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">])</span></p>
    <p><br>
    </p>
    <blockquote type="cite"
      cite="mid:df4b0646-78dc-c23b-3dae-46e7281b7d9f@free.fr">
      <br>
      Est-il possible de changer le mot de passe d'un utilisateur avec
      un paquet ? (Car j'ai un compte local identique sur toutes les
      machines et j'aimerais changer son mot de passe de temps en temps)
      <br>
    </blockquote>
    <p><br>
    </p>
    <p>Là encore, un simple run peut le faire <br>
    </p>
    <p><br>
    </p>
    <p><span style="color: rgb(51, 51, 51); font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">    run(</span><span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">'net user dani %s'</span><span style="color: rgb(51, 51, 51); font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"> % variables[</span><span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">'pass'</span><span style="color: rgb(51, 51, 51); font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">])</span></p>
    <p><br>
    </p>
    <p>Par contre, il faut prendre des précautions pour que ce mot de
      passe ne soit pas visible en clair dans le paquet. Dans mon cas,
      je déploie un paquet contenant des variables (une structure YAML)
      chiffrées, et je déploie sur chaque poste la clé symétrique
      nécessaire à leur lecture. Quelque chose comme :</p>
    <p><br>
    </p>
    <ol class="linenums" style="box-sizing: inherit; font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px; background-color: rgb(255, 255, 255); margin: 0px; padding: 0px !important; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"><li class="L14" rel="L14" style="box-sizing: inherit; font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px; display: block; width: 1664px;"><span class="hljs-comment" style="box-sizing: inherit; color: rgb(153, 153, 136); font-style: italic; font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;"># Read local variables file if available</span>
</li><li class="L15" rel="L15" style="box-sizing: inherit; font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px; display: block; width: 1664px;"><span class="hljs-keyword" style="box-sizing: inherit; color: rgb(51, 51, 51); font-weight: bold; font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">if</span> isfile(makepath(programfiles32,<span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">'wapt'</span>,<span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">'private'</span>,<span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">'symetric.txt'</span>)) <span class="hljs-keyword" style="box-sizing: inherit; color: rgb(51, 51, 51); font-weight: bold; font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">and</span> isfile(makepath(programfiles32,<span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">'wapt'</span>,<span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">'private'</span>,<span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">'variables.txt'</span>)):
</li><li class="L16" rel="L16" style="box-sizing: inherit; font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px; display: block; width: 1664px;">    print(<span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">'Reading local encrypted variables file'</span>)
</li><li class="L17" rel="L17" style="box-sizing: inherit; font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px; display: block; width: 1664px;">    <span class="hljs-keyword" style="box-sizing: inherit; color: rgb(51, 51, 51); font-weight: bold; font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">from</span> cryptography.fernet <span class="hljs-keyword" style="box-sizing: inherit; color: rgb(51, 51, 51); font-weight: bold; font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">import</span> Fernet
</li><li class="L18" rel="L18" style="box-sizing: inherit; font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px; display: block; width: 1664px;">    <span class="hljs-keyword" style="box-sizing: inherit; color: rgb(51, 51, 51); font-weight: bold; font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">import</span> yaml
</li><li class="L19" rel="L19" style="box-sizing: inherit; font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px; display: block; width: 1664px;">    f = Fernet(open(makepath(programfiles32,<span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">'wapt'</span>,<span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">'private'</span>,<span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">'symetric.txt'</span>),<span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">'r'</span>).read())
</li><li class="L20" rel="L20" style="box-sizing: inherit; font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px; display: block; width: 1664px;">    variables.update(yaml.safe_load(f.decrypt(open(makepath(programfiles32,<span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">'wapt'</span>,<span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">'private'</span>,<span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">'variables.txt'</span>),<span class="hljs-string" style="box-sizing: inherit; color: rgb(221, 17, 68); font-size: 12px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 20px;">'r'</span>).read())))</li></ol>
    <br>
  </body>
</html>