def change_group(name, group, user): e = get() if not e[0]: return e if name not in e[1]: return (False, [N_("account not found:"), name]) old = e[1][name]["g"] if old == group: return (False, [N_("same group:"), group]) e = _change_group_in_conf(name, group, e[1]) if not e[0]: return e data = e[1] e = _change_group_in_system(name, group, old) if not e[0]: return e xt_func.save_json(const.CFG_DIR + USER_TABLE, data) xtd_logd.add_log(user+ " change group of account: "+ name+ " to "+ group) return (True, [])
def set_datetime(data, user): ret = (True, None) xtd_logd.add_log(user + " apply " + TAG) timestr = ".".join(data[0:3]) + "-" + ":".join(data[3:6]) e = xt_func.sudo(["date -s", timestr]) if not e[0]: ret = (False, N_("See failure.log")) e = xt_func.sudo(["hwclock -w"]) if not e[0]: ret = (False, N_("See failure.log")) return ret
def add_account(name, param, user): e = get() if not e[0]: return e e = _add_account_to_conf(name, param, e[1]) if not e[0]: return e data = e[1] e = _add_account_to_system(name, param) if not e[0]: return e xt_func.save_json(const.CFG_DIR + USER_TABLE, data) xtd_logd.add_log(user + " add account: " + name) return (True, [])
def change_password(name, password, user): e = get() if not e[0]: return e e = _change_password_in_conf(name, password, e[1]) if not e[0]: return e data = e[1] e = _change_password_in_system(name, password) if not e[0]: return e xt_func.save_json(const.CFG_DIR + USER_TABLE, data) xtd_logd.add_log(user + " change password of account: " + name) return (True, [])
def delete_account(name, user): e = get() if not e[0]: return e if name not in e[1]: return (False, [N_("account not found:"), name]) group = e[1][name]["g"] e = _delete_account_in_conf(name, e[1]) if not e[0]: return e data = e[1] e = _delete_account_in_system(name, group) if not e[0]: return e xt_func.save_json(const.CFG_DIR + USER_TABLE, data) xtd_logd.add_log(user + " delete account: " + name) return (True, [])