+
+ filter = "(gid=%s)" % name
+ res = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,filter,["gidNumber"]);
+ if res:
+ return int(GetAttr(res[0], "gidNumber"))
+
+ return -1
+
+def make_hmac(str):
+ if 'UD_HMAC_KEY' in os.environ:
+ HmacKey = os.environ['UD_HMAC_KEY']
+ else:
+ File = open(PassDir+"/key-hmac-"+pwd.getpwuid(os.getuid())[0],"r");
+ HmacKey = File.readline().strip()
+ File.close();
+ return hmac.new(HmacKey, str, sha1_module).hexdigest()
+
+def make_passwd_hmac(status, purpose, uid, uuid, hosts, cryptedpass):
+ return make_hmac(':'.join([status, purpose, uid, uuid, hosts, cryptedpass]))