From c91a1c93cb0ec61ecf9c9a3d6e4cf53372af2dd5 Mon Sep 17 00:00:00 2001 From: mysticbbs Date: Mon, 13 Aug 2012 18:54:00 -0400 Subject: [PATCH] Now switches to the user/group that owns the executable on startup. --- mystic/mis.pas | 21 +++++++++++++++++++++ mystic/mystic.pas | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/mystic/mis.pas b/mystic/mis.pas index 265d978..fc93017 100644 --- a/mystic/mis.pas +++ b/mystic/mis.pas @@ -337,6 +337,23 @@ Begin SwitchFocus; End; +{$IFDEF UNIX} +Procedure SetUserOwner; +Var + Info : Stat; + MysLoc : String; +Begin + MysLoc := GetEnv('mysticbbs'); + + If MysLoc <> '' Then MysLoc := DirSlash(MysLoc); + + If fpStat(MysLoc + 'mis', Info) = 0 Then Begin + fpSetGID (Info.st_GID); + fpSetUID (Info.st_UID); + End; +End; +{$ENDIF} + Function ServerStartup : Boolean; Begin Result := False; @@ -393,6 +410,10 @@ Begin Result := True; End; + + {$IFDEF UNIX} + SetUserOwner; + {$ENDIF} End; {$IFDEF UNIX} diff --git a/mystic/mystic.pas b/mystic/mystic.pas index c434131..f15becc 100644 --- a/mystic/mystic.pas +++ b/mystic/mystic.pas @@ -182,7 +182,13 @@ Procedure Linux_Init; Var Count : Word; TChat : ChatRec; + Info : Stat; Begin + If fpStat('mystic', Info) = 0 Then Begin + fpSetGID (Info.st_GID); + fpSetUID (Info.st_UID); + End; + Session.NodeNum := 0; For Count := 1 to Config.INetTNNodes Do Begin