home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume8 / xlogin / part01 / xdm.patch02 < prev    next >
Text File  |  1990-07-11  |  3KB  |  96 lines

  1. Also, I thought that I would share my changes to xdm.  I have changed
  2. xdm to write an authorization record for root.  I feel that this does
  3. not compromise security at all.  root could also setuid to the user
  4. to gain access to the display.  I have written a daemon that catches
  5. console message and displays them in a window.  Also, we have a system
  6. that submits jobs on idle workstations.  This system can connect to
  7. the X display to check the idle time.  Anyway, here is my patch to xdm:
  8.  
  9.  
  10. *** /tmp/,RCSt1a23628    Sun Jul  8 14:39:22 1990
  11. --- auth.c    Wed Jun 13 14:03:25 1990
  12. ***************
  13. *** 201,206 ****
  14. --- 201,207 ----
  15.           ret = TRUE;
  16.       fclose (auth_file);
  17.       }
  18. +     SetRootAuthorization (d, auth);
  19.       return ret;
  20.   }
  21.   
  22. ***************
  23. *** 778,781 ****
  24. --- 779,849 ----
  25.       }
  26.       }
  27.       Debug ("done SetUserAuthorization\n");
  28. + }
  29. + SetRootAuthorization (d, auth)
  30. + struct display    *d;
  31. + Xauth        *auth;
  32. + {
  33. +     FILE    *old, *new;
  34. +     char    *home_name;
  35. +     char    new_name[1024];
  36. +     int    lockStatus;
  37. +     Xauth    *entry;
  38. +     struct stat    statb;
  39. +     Debug ("SetRootAuthorization\n");
  40. +     if (auth) {
  41. +     lockStatus = LOCK_ERROR;
  42. +     home_name = "/.Xauthority";
  43. +     Debug ("XauLockAuth %s\n", home_name);
  44. +     lockStatus = XauLockAuth (home_name, 1, 2, 10);
  45. +     Debug ("Lock is %d\n", lockStatus);
  46. +     if (lockStatus == LOCK_SUCCESS) {
  47. +         if (!openFiles (home_name, new_name, &old, &new)) {
  48. +         Debug ("openFiles failed\n");
  49. +         XauUnlockAuth (home_name);
  50. +         lockStatus = LOCK_ERROR;
  51. +         }    
  52. +     }
  53. +     if (lockStatus != LOCK_SUCCESS) {
  54. +         Debug ("can't lock auth file %s\n", home_name);
  55. +         LogError ("can't lock authorization file %s\n", home_name);
  56. +         return;
  57. +     }
  58. +     initAddrs ();
  59. +     if (d->displayType.location == Local)
  60. +         writeLocalAuth (new, auth, d->name);
  61. +     else
  62. +         writeRemoteAuth (new, auth, d->peer, d->peerlen, d->name);
  63. +     if (old) {
  64. +         if (fstat (fileno (old), &statb) != -1)
  65. +         chmod (new_name, (int) (statb.st_mode & 0777));
  66. +         while (entry = XauReadAuth (old)) {
  67. +         if (!checkAddr (entry->family,
  68. +                    entry->address_length, entry->address,
  69. +                    entry->number_length, entry->number))
  70. +         {
  71. +             Debug ("Saving an entry\n");
  72. +             dumpAuth (entry);
  73. +             writeAuth (new, entry);
  74. +         }
  75. +         XauDisposeAuth (entry);
  76. +         }
  77. +         fclose (old);
  78. +     }
  79. +     doneAddrs ();
  80. +     fclose (new);
  81. +     if (unlink (home_name) == -1)
  82. +         Debug ("unlink %s failed\n", home_name);
  83. +     if (link (new_name, home_name) == -1) {
  84. +         Debug ("link failed %s %s\n", new_name, home_name);
  85. +         LogError ("Can't move authorization into place\n");
  86. +     } else {
  87. +         Debug ("new is in place, go for it!\n");
  88. +         unlink (new_name);
  89. +     }
  90. +     XauUnlockAuth (home_name);
  91. +     }
  92. +     Debug ("done SetRootAuthorization\n");
  93.   }
  94.