* Dotted filenames for package users

This commit is contained in:
Michaël Van Canneyt 2023-03-06 14:57:57 +01:00
parent 0707b5f7ca
commit 2c6d0fb7f2
11 changed files with 55 additions and 5 deletions

View File

@ -0,0 +1,3 @@
unit UnixApi.Crypth;
{$DEFINE FPC_DOTTEDUNITS}
{$i crypth.pp}

View File

@ -0,0 +1,3 @@
unit UnixApi.Grp;
{$DEFINE FPC_DOTTEDUNITS}
{$i grp.pp}

View File

@ -0,0 +1,3 @@
unit UnixApi.Pwd;
{$DEFINE FPC_DOTTEDUNITS}
{$i pwd.pp}

View File

@ -0,0 +1,3 @@
unit UnixApi.Shadow;
{$DEFINE FPC_DOTTEDUNITS}
{$i shadow.pp}

View File

@ -0,0 +1,3 @@
unit UnixApi.Users;
{$DEFINE FPC_DOTTEDUNITS}
{$i users.pp}

View File

@ -0,0 +1,7 @@
src/crypth.pp=namespaced/UnixApi.Crypth.pp
{s*:src/}=namespaced/
{i+:src/}
src/pwd.pp=namespaced/UnixApi.Pwd.pp
src/shadow.pp=namespaced/UnixApi.Shadow.pp
src/users.pp=namespaced/UnixApi.Users.pp
src/grp.pp=namespaced/UnixApi.Grp.pp

View File

@ -1,8 +1,14 @@
{$IFNDEF FPC_DOTTEDUNITS}
unit crypth;
{$ENDIF FPC_DOTTEDUNITS}
interface
{$IFDEF FPC_DOTTEDUNITS}
uses UnixApi.Base,System.InitC;
{$ELSE FPC_DOTTEDUNITS}
uses BaseUnix,initc;
{$ENDIF FPC_DOTTEDUNITS}
{$ifdef Linux}{$linklib crypt}{$endif}
@ -11,4 +17,4 @@ Const libname ={$ifdef Linux}'crypt'{$else}clib{$endif};
function crypt(key,salt:PAnsiChar):PAnsiChar;cdecl; external libname name 'crypt';
implementation
end.
end.

View File

@ -1,9 +1,16 @@
{$IFNDEF FPC_DOTTEDUNITS}
unit grp;
{$ENDIF FPC_DOTTEDUNITS}
interface
{$IFDEF FPC_DOTTEDUNITS}
uses
System.InitC,UnixApi.Types,UnixApi.Base,System.CTypes;
{$ELSE FPC_DOTTEDUNITS}
uses
initc,unixtype,baseunix,ctypes;
{$ENDIF FPC_DOTTEDUNITS}
{$IFDEF FPC}
{$PACKRECORDS C}

View File

@ -1,9 +1,16 @@
{$IFNDEF FPC_DOTTEDUNITS}
unit pwd;
{$ENDIF FPC_DOTTEDUNITS}
interface
{$IFDEF FPC_DOTTEDUNITS}
uses
System.InitC,UnixApi.Types,UnixApi.Base,System.CTypes;
{$ELSE FPC_DOTTEDUNITS}
uses
initc,unixtype,baseunix,ctypes;
{$ENDIF FPC_DOTTEDUNITS}
{$IFDEF FPC}
{$PACKRECORDS C}

View File

@ -1,4 +1,6 @@
{$IFNDEF FPC_DOTTEDUNITS}
unit shadow;
{$ENDIF FPC_DOTTEDUNITS}
interface
{

View File

@ -1,8 +1,14 @@
{$IFNDEF FPC_DOTTEDUNITS}
unit users;
{$ENDIF FPC_DOTTEDUNITS}
Interface
{$mode delphi}
{$IFDEF FPC_DOTTEDUNITS}
uses UnixApi.Types,UnixApi.Base,UnixApi.Pwd,UnixApi.Grp, {$ifdef Linux} UnixApi.Shadow,{$endif}System.SysUtils,System.Classes;
{$ELSE FPC_DOTTEDUNITS}
uses UnixType,BaseUnix,pwd,grp, {$ifdef Linux} shadow,{$endif}SysUtils,Classes;
{$ENDIF FPC_DOTTEDUNITS}
Type
EUserLookupError = Class(Exception);
@ -64,7 +70,7 @@ EShadowNotPermitted = 'Not enough permissions to access shadow password file';
Function getpwnam(Const UserName: AnsiString) : PPasswordRecord;
begin
Result:=pwd.fpgetpwnam(PAnsiChar(UserName));
Result:={$IFDEF FPC_DOTTEDUNITS}UnixApi.{$ENDIF}Pwd.fpgetpwnam(PAnsiChar(UserName));
end;
Procedure GetUserData(Const UserName : AnsiString; Var Data : TPasswordRecord);
@ -179,7 +185,7 @@ end;
Function getgrnam(Const GroupName: AnsiString) : PGroup;
begin
Result:=grp.fpgetgrnam(PAnsiChar(GroupName));
Result:={$IFDEF FPC_DOTTEDUNITS}UnixApi.{$ENDIF}Grp.fpgetgrnam(PAnsiChar(GroupName));
end;
Procedure GetGroupData(Const GroupName : AnsiString; Var Data : TGroup); overload;
@ -294,13 +300,13 @@ end;
function getspnam(UserName : AnsiString): PPasswordFileEntry;
begin
result:=shadow.getspnam(PAnsiChar(UserName));
result:={$IFDEF FPC_DOTTEDUNITS}UnixApi.{$ENDIF}Shadow.getspnam(PAnsiChar(UserName));
end;
function sgetspent(Line : AnsiString): PPasswordFileEntry;
begin
Result:=shadow.sgetspent(PAnsiChar(Line));
Result:={$IFDEF FPC_DOTTEDUNITS}UnixApi.{$ENDIF}shadow.sgetspent(PAnsiChar(Line));
end;
Procedure GetUserShadowData(Const UserName : AnsiString; Var Data : TPasswordFileEntry);