+ /* Failing that, see if LOGNAME or USER exist and differ from
+ our euid. If so, look for a socket based on the UID
+ associated with the name. This is reminiscent of the logic
+ that init_editfns uses to set the global Vuser_full_name. */
+
+ char *user_name = (char *) getenv ("LOGNAME");
+ if (!user_name)
+ user_name = (char *) getenv ("USER");
+
+ if (user_name)
+ {
+ struct passwd *pw = getpwnam (user_name);
+ if (pw && (pw->pw_uid != geteuid ()))
+ {
+ /* We're running under su, apparently. */
+ sprintf (server.sun_path, "/tmp/esrv%d-%s",
+ pw->pw_uid, system_name);
+ sock_status = socket_status (server.sun_path);
+ }
+ }