def generate_smb_conf(): try: d, err = cifs_common.load_auth_settings() if err: raise Exception(err) smb_conf_path, err = common.get_smb_conf_path() if err: raise Exception(err) with open("%s/smb.conf"%smb_conf_path, "w+") as f: ret, err = cifs_common.generate_global_header(f) if err: raise Exception(err) ret, err = _generate_unicell_specific_global_section(f) if err: raise Exception(err) ret, err = cifs_common.generate_common_global_section(f, d) if err: raise Exception(err) shl, err = cifs_common.load_shares_list() if err: raise Exception(err) if shl: for share in shl: ul = [] gl = [] if not share["guest_ok"]: vul, err = cifs_common.load_valid_users_list(share["share_id"]) if err: raise Exception(err) if vul: for vu in vul: if vu["grp"]: gl.append(vu["name"]) else: ul.append(vu["name"]) ret, err = _generate_share_section(f, share["name"], d["workgroup"], share["path"], share["read_only"], share["browseable"], share["guest_ok"], ul, gl, share["comment"], d["security"]) if err: raise Exception(err) ret, errors = _reload_config() if errors: raise Exception(errors) except Exception, e: return False, 'Error generating CIFS configuration : %s'%str(e)
def generate_smb_conf(): d = load_auth_settings() with open("%s/smb.conf"%common.get_smb_conf_path(), "w+") as f: _generate_global_section(f, d) shl = load_shares_list() if shl: for share in shl: ul = [] gl = [] if not share["guest_ok"]: vul = load_valid_users_list(share["share_id"]) if vul: for vu in vul: if vu["grp"]: gl.append(vu["name"]) else: ul.append(vu["name"]) _generate_share_section(f, share["name"], share["vol"], d["workgroup"], share["path"], share["read_only"], share["browseable"], share["guest_ok"], ul, gl, share["comment"], d["security"]) f.close() errors = _reload_config() if errors != '': raise Exception(errors)