From 51f98437460dd3adac2cacd9510551dd2f3d54a7 Mon Sep 17 00:00:00 2001 From: jgg <> Date: Thu, 23 Sep 1999 03:01:12 +0000 Subject: [PATCH] Fixes --- doc/ud-xearth.1.yo | 2 +- ud-generate | 32 +++++++++++++++++++++++++++++++- ud-replicate | 1 + ud-xearth | 34 ++-------------------------------- userdir_ldap.py | 30 ++++++++++++++++++++++++++++++ 5 files changed, 65 insertions(+), 34 deletions(-) diff --git a/doc/ud-xearth.1.yo b/doc/ud-xearth.1.yo index 52140c1..2f363ba 100644 --- a/doc/ud-xearth.1.yo +++ b/doc/ud-xearth.1.yo @@ -17,7 +17,7 @@ Since lat/long information is restricted to developers only a valid login is required to extract the information. A good way to make use of the coordinates is the following command: -verb(xplanet --shade 100 --marker developers.coords --color white \ +verb(xplanet --shade 100 --marker_ developers.coords --color white \ --output developers.map.jpeg --geometry 750x450) manpageoptions() diff --git a/ud-generate b/ud-generate index 6b004f0..a0d5d7c 100755 --- a/ud-generate +++ b/ud-generate @@ -195,6 +195,34 @@ def GenForward(l,File,Allowed): raise; Done(File,F,Fdb); +# Generate the anon XEarth marker file +def GenMarkers(l,File): + F = None; + Fdb = None; + try: + F = open(File + ".tmp","w"); + Fdb = None; + + # Fetch all the users + global PasswdAttrs; + if PasswdAttrs == None: + raise "No Users"; + + # Write out the email address for each user + for x in PasswdAttrs: + if x[1].has_key("latitude") == 0 or x[1].has_key("longitude") == 0: + continue; + try: + F.write("%8s %8s \"\"\n"%(DecDegree(x,"latitude",1),DecDegree(x,"longitude",1))); + except: + pass; + + # Oops, something unspeakable happened. + except: + Die(F,Fdb); + raise; + Done(File,F,Fdb); + # Connect to the ldap server l = ldap.open(LDAPServer); F = open(PassDir+"/pass-"+pwd.getpwuid(posix.getuid())[0],"r"); @@ -218,7 +246,7 @@ PasswdAttrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid=*",\ ["uid","uidnumber","gidnumber","supplementarygid",\ "gecos","loginshell","userpassword","shadowlastchange",\ "shadowmin","shadowmax","shadowwarning","shadowinactive", - "shadowexpire","emailforward"]); + "shadowexpire","emailforward","latitude","longitude"]); # Open the control file if len(sys.argv) == 1: @@ -251,3 +279,5 @@ while(1): GenGroup(l,OutDir+"group",GroupList); GenShadow(l,OutDir+"shadow",GroupList); GenForward(l,OutDir+"forward-alias",GroupList); + GenMarkers(l,OutDir+"markers"); + diff --git a/ud-replicate b/ud-replicate index c69c6b8..1439847 100755 --- a/ud-replicate +++ b/ud-replicate @@ -6,6 +6,7 @@ HOST=`hostname -f` cd /tmp/ cd /var/lib/misc > /dev/null 2>&1 || cd /var/state/glibc/ > /dev/null 2>&1 || cd /var/db/ > /dev/null 2>&1 lockfile -r 1 -l 3600 lock +trap "rm -f lock > /dev/null 2>&1" exit rsync -e ssh -rp sshdist@samosa:/var/cache/userdir-ldap/hosts/$HOST . > /dev/null 2>&1 makedb $HOST/passwd.tdb -o passwd.db > /dev/null 2>&1 makedb $HOST/shadow.tdb -o shadow.db > /dev/null 2>&1 diff --git a/ud-xearth b/ud-xearth index cec3308..9679866 100755 --- a/ud-xearth +++ b/ud-xearth @@ -19,36 +19,6 @@ from userdir_ldap import *; Anon = 0; -# This needs to check for leading 0 to disambiguate some things -def DecDegree(Attr,Type): - Parts = re.match('[+-]?(\d*)\\.?(\d*)?',GetAttr(Attr,Type)).groups(); - Val = string.atof(GetAttr(Attr,Type)); - - if (abs(Val) >= 1806060.0): - raise ValueError,"Too Big"; - - # Val is in DGMS - if abs(Val) >= 18060.0 or len(Parts[0]) > 5: - Val = Val/100.0; - Secs = Val - long(Val); - Val = long(Val)/100.0; - Min = Val - long(Val); - Val = long(Val) + (Min*100.0 + Secs*100.0/60.0)/60.0; - - # Val is in DGM - elif abs(Val) >= 180 or len(Parts[0]) > 3: - Val = Val/100.0; - Min = Val - long(Val); - Val = long(Val) + Min*100.0/60.0; - - if Anon != 0: - Str = "%3.3f"%(Val); - else: - Str = str(Val); - if Val >= 0: - return "+" + Str; - return Str; - # Main program starts here User = pwd.getpwuid(posix.getuid())[0]; BindUser = User; @@ -82,9 +52,9 @@ for x in Attrs: Count = Count + 1; try: if Anon != 0: - F.write("%8s %8s \"\"\n"%(DecDegree(x,"latitude"),DecDegree(x,"longitude"))); + F.write("%8s %8s \"\"\n"%(DecDegree(x,"latitude",Anon),DecDegree(x,"longitude",Anon))); else: - F.write("%16s %16s \"%s\" \t# %s\n"%(DecDegree(x,"latitude"),DecDegree(x,"longitude"),GetAttr(x,"uid"),EmailAddress(x))); + F.write("%16s %16s \"%s\" \t# %s\n"%(DecDegree(x,"latitude",Anon),DecDegree(x,"longitude",Anon),GetAttr(x,"uid"),EmailAddress(x))); except: Failed = Failed + 1; if Anon == 0: diff --git a/userdir_ldap.py b/userdir_ldap.py index eab3cab..21b215b 100644 --- a/userdir_ldap.py +++ b/userdir_ldap.py @@ -168,3 +168,33 @@ def FlushOutstanding(l,Outstanding,Fast=0): if Fast == 0: print; return Outstanding; + +# Convert a lat/long attribute into Decimal degrees +def DecDegree(Attr,Type,Anon=0): + Parts = re.match('[+-]?(\d*)\\.?(\d*)?',GetAttr(Attr,Type)).groups(); + Val = string.atof(GetAttr(Attr,Type)); + + if (abs(Val) >= 1806060.0): + raise ValueError,"Too Big"; + + # Val is in DGMS + if abs(Val) >= 18060.0 or len(Parts[0]) > 5: + Val = Val/100.0; + Secs = Val - long(Val); + Val = long(Val)/100.0; + Min = Val - long(Val); + Val = long(Val) + (Min*100.0 + Secs*100.0/60.0)/60.0; + + # Val is in DGM + elif abs(Val) >= 180 or len(Parts[0]) > 3: + Val = Val/100.0; + Min = Val - long(Val); + Val = long(Val) + Min*100.0/60.0; + + if Anon != 0: + Str = "%3.2f"%(Val); + else: + Str = str(Val); + if Val >= 0: + return "+" + Str; + return Str; -- 2.20.1