RxFPC:fix compile on windows. On linux work with winbind user name

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4641 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2016-05-11 06:09:35 +00:00
parent 148d4298db
commit a6fd807723
2 changed files with 39 additions and 35 deletions

View File

@ -12,10 +12,10 @@ object Form1: TForm1
AnchorSideTop.Control = Owner AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 322 Left = 335
Height = 32 Height = 23
Top = 6 Top = 6
Width = 113 Width = 100
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -30,8 +30,8 @@ object Form1: TForm1
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 12 Left = 12
Height = 30 Height = 21
Top = 70 Top = 54
Width = 423 Width = 423
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -46,8 +46,8 @@ object Form1: TForm1
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 12 Left = 12
Height = 30 Height = 21
Top = 132 Top = 100
Width = 423 Width = 423
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -62,8 +62,8 @@ object Form1: TForm1
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 10 Left = 10
Height = 30 Height = 21
Top = 282 Top = 211
Width = 425 Width = 425
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -78,8 +78,8 @@ object Form1: TForm1
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 12 Left = 12
Height = 30 Height = 21
Top = 344 Top = 257
Width = 423 Width = 423
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -92,9 +92,9 @@ object Form1: TForm1
AnchorSideTop.Control = Button1 AnchorSideTop.Control = Button1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 20 Height = 13
Top = 44 Top = 35
Width = 251 Width = 188
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'User name (from environment variable)' Caption = 'User name (from environment variable)'
ParentColor = False ParentColor = False
@ -104,11 +104,11 @@ object Form1: TForm1
AnchorSideTop.Control = Edit1 AnchorSideTop.Control = Edit1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 20 Height = 13
Top = 106 Top = 81
Width = 80 Width = 59
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'User domani' Caption = 'User domain'
ParentColor = False ParentColor = False
end end
object Label3: TLabel object Label3: TLabel
@ -116,9 +116,9 @@ object Form1: TForm1
AnchorSideTop.Control = DividerBevel1 AnchorSideTop.Control = DividerBevel1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 20 Height = 13
Top = 194 Top = 146
Width = 55 Width = 40
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'File info:' Caption = 'File info:'
ParentColor = False ParentColor = False
@ -130,8 +130,8 @@ object Form1: TForm1
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 0 Left = 0
Height = 20 Height = 13
Top = 168 Top = 127
Width = 441 Width = 441
Caption = 'File owner' Caption = 'File owner'
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
@ -147,8 +147,8 @@ object Form1: TForm1
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 12 Left = 12
Height = 30 Height = 21
Top = 220 Top = 165
Width = 423 Width = 423
FilterIndex = 0 FilterIndex = 0
HideDirectories = False HideDirectories = False
@ -164,9 +164,9 @@ object Form1: TForm1
AnchorSideTop.Control = FileNameEdit1 AnchorSideTop.Control = FileNameEdit1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 4 Left = 4
Height = 20 Height = 13
Top = 256 Top = 192
Width = 83 Width = 61
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Owner name' Caption = 'Owner name'
ParentColor = False ParentColor = False
@ -176,9 +176,9 @@ object Form1: TForm1
AnchorSideTop.Control = Edit3 AnchorSideTop.Control = Edit3
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 20 Height = 13
Top = 318 Top = 238
Width = 94 Width = 69
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Owner domain' Caption = 'Owner domain'
ParentColor = False ParentColor = False

View File

@ -49,7 +49,7 @@ uses
{$IFDEF WINDOWS} {$IFDEF WINDOWS}
Windows Windows
{$ELSE} {$ELSE}
BaseUnix, users BaseUnix, users, strutils
{$ENDIF}; {$ENDIF};
(* (*
FileUtil, LazFileUtils, LazUTF8; FileUtil, LazFileUtils, LazUTF8;
@ -82,8 +82,6 @@ begin
Result := Result + Tmp; Result := Result + Tmp;
end; end;
{ TODO -oalexs : In future need rewrite this code for fix mem leak }
procedure GetFileNameOwner(const SearchDomain, FileName: String; out UserName, DomainName: string); procedure GetFileNameOwner(const SearchDomain, FileName: String; out UserName, DomainName: string);
var var
RCode, RC1:WINBOOL; RCode, RC1:WINBOOL;
@ -154,8 +152,11 @@ end;
procedure GetFileOwnerData(const SearchDomain, FileName: String; out UserName, procedure GetFileOwnerData(const SearchDomain, FileName: String; out UserName,
DomainName: string); DomainName: string);
{$IF DEFINED(WINDOWS) AND NOT DEFINED(WINCE)}
{$ELSE}
var var
SR: stat; SR: stat;
{$ENDIF}
begin begin
{$IF DEFINED(WINDOWS) AND NOT DEFINED(WINCE)} {$IF DEFINED(WINDOWS) AND NOT DEFINED(WINCE)}
{ GetFileNameOwner(UTF8ToSys(SearchDomain), UTF8ToSys(FileName), UserName, DomainName); { GetFileNameOwner(UTF8ToSys(SearchDomain), UTF8ToSys(FileName), UserName, DomainName);
@ -165,7 +166,10 @@ begin
{$ELSE} {$ELSE}
FpStat(FileName, SR); FpStat(FileName, SR);
UserName:=users.GetUserName(SR.uid); UserName:=users.GetUserName(SR.uid);
DomainName:='';//IntToStr( SR.gid); if Pos('\', UserName) > 0 then
DomainName:=Copy2SymbDel(UserName, '\') //for unix samba WinBIND
else
DomainName:='';//IntToStr( SR.gid);
{$ENDIF} {$ENDIF}
end; end;