<div dir="ltr">Hi All,<div>This patch adds a tuning knob (environment variable) to not expire the root password.<br clear="all"><div><br></div><div>Use case: One wants to set the root password when creating the container, so he/she doesn't want to the password to be expired.</div>

<div><br></div><div>Usage:</div><div><font face="courier new, monospace">root_password="<root password for the container>" root_expire_password=no lxc-create -t centos -n <container name></font></div>

<div><br></div><div><div style="font-family:arial,sans-serif;font-size:12.800000190734863px"><font face="arial, sans-serif">Signed-off-by: Mingjiang Shi <mrjewes at gmail dot com></font><br></div></div><div style="font-family:arial,sans-serif;font-size:12.800000190734863px">

<font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">---</font></div><div><font face="arial, sans-serif"><div>diff --git a/templates/<a href="http://lxc-centos.in">lxc-centos.in</a> b/templates/<a href="http://lxc-centos.in">lxc-centos.in</a></div>

<div>index 55e0531..93f4f93 100644</div><div>--- a/templates/<a href="http://lxc-centos.in">lxc-centos.in</a></div><div>+++ b/templates/<a href="http://lxc-centos.in">lxc-centos.in</a></div><div>@@ -43,10 +43,12 @@ default_path=@LXCPATH@</div>

<div> #</div><div> # If root_display_password = yes, display the temporary root password at exit.</div><div> # If root_store_password = yes, store it in the configuration directory</div><div> # If root_prompt_password = yes, invoke "passwd" to force the user to change</div>

<div> # the root password after the container is created.</div><div>+# If root_expire_password = yes, you will be prompted to change the root</div><div>+# password at the first login.</div><div> #</div><div> # These are conditional assignments...  The can be overridden from the</div>

<div> # preexisting environment variables...</div><div> #</div><div> # Make sure this is in single quotes to defer expansion to later!</div><div>@@ -59,10 +61,14 @@ default_path=@LXCPATH@</div><div> : ${root_store_password='yes'}</div>

<div> # Prompting for something interactive has potential for mayhem</div><div> # with users running under the API...  Don't default to "yes"</div><div> : ${root_prompt_password='no'}</div><div> </div>

<div>+# Expire root password? Default to yes, but can be overridden from</div><div>+# the environment variable</div><div>+: ${root_expire_password='yes'}</div><div>+</div><div> # These are only going into comments in the resulting config...</div>

<div> lxc_network_type=veth</div><div> lxc_network_link=lxcbr0</div><div> </div><div> # is this centos?</div><div>@@ -337,12 +343,14 @@ EOF</div><div>         echo ${root_password} > ${config_path}/tmp_root_pass</div>
<div>
         echo "Storing root password in '${config_path}/tmp_root_pass'"</div><div>     fi</div><div> </div><div>     echo "root:$root_password" | chroot $rootfs_path chpasswd</div><div>-    # Also set this password as expired to force the user to change it!</div>

<div>-    chroot $rootfs_path passwd -e root</div><div>+    if [ ${root_expire_password} == "yes" ];then</div><div>+        # set this password as expired to force the user to change it!</div><div>+        chroot $rootfs_path passwd -e root</div>

<div>+    fi</div><div> </div><div>     # This will need to be enhanced for CentOS 7 when systemd</div><div>     # comes into play...   /\/\|=mhw=|\/\/</div><div> </div><div>     return 0</div><div>@@ -879,15 +887,17 @@ then</div>

<div> </div><div>         chroot ${rootfs_path} passwd</div><div> "</div><div>     chroot ${rootfs_path} passwd</div><div> else</div><div>-    echo "</div><div>-The root password is set up as "expired" and will require it to be changed</div>

<div>-at first login, which you should do as soon as possible.  If you lose the</div><div>-root password or wish to change it without starting the container, you</div><div>-can change it from the host by running the following command (which will</div>

<div>-also reset the expired flag):</div><div>-</div><div>-        chroot ${rootfs_path} passwd</div><div>-"</div><div>+    if [ ${root_expire_password} = "yes" ];then</div><div>+        echo "</div><div>

+    The root password is set up as "expired" and will require it to be changed</div><div>+    at first login, which you should do as soon as possible.  If you lose the</div><div>+    root password or wish to change it without starting the container, you</div>

<div>+    can change it from the host by running the following command (which will</div><div>+    also reset the expired flag):</div><div>+    </div><div>+            chroot ${rootfs_path} passwd</div><div>+    "</div>

<div>+    fi</div><div> fi</div></font></div><div><font face="arial, sans-serif">---</font></div>-- <br>Thanks<br>-Mingjiang
</div></div>