文件操作 - handle-sshpw
返回文件管理
返回主菜单
删除本文件
文件: /usr/sbin/handle-sshpw
编辑文件内容
#!/usr/bin/python # # handle-sshpw: Code processing sshpw lines in kickstart files for the # install environment. # # Copyright (C) 2012-2016 Red Hat, Inc. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # # Author(s): Jesse Keating <jkeating@redhat.com> # # Some of this code comes from the old pyanaconda/sshd.py # import os import sys from pykickstart.parser import KickstartParser from pykickstart.version import makeVersion from pykickstart.sections import NullSection import pyanaconda.users as users ksfile = '/run/install/ks.cfg' # see if we have a file to work with if not os.path.exists(ksfile): sys.exit() handler = makeVersion() ksparser = KickstartParser(handler, missingIncludeIsFatal=False) ksparser.registerSection(NullSection(handler, sectionOpen="%addon")) ksparser.registerSection(NullSection(handler, sectionOpen="%anaconda")) ksparser.readKickstart(ksfile) # we need to have a libuser.conf that points to the installer root for # sshpw, but after that we start sshd, we need one that points to the # install target. luserConf = users.createLuserConf(instPath="") u = users.Users() userdata = ksparser.handler.sshpw.dataList() for ud in userdata: if u.checkUserExists(ud.username, root="/"): if not ud.sshkey: u.setUserPassword(username=ud.username, password=ud.password, isCrypted=ud.isCrypted, lock=ud.lock) else: kwargs = ud.__dict__ kwargs.update({"root": "/", "mkmailspool": False}) u.createUser(ud.username, **kwargs) if ud.sshkey: # Setup the account so that only the sshkey can be used u.setUserPassword(username=ud.username, password="*", isCrypted=True, lock=False) u.setUserSshKey(username=ud.username, key=ud.password, root="/")
修改文件时间
将文件时间修改为当前时间的前一年
删除文件