Forum
× CodeTyphon MacOS Development, discussions and problems

Question using SysCall and manipulating file permissions on macOS

  • Inferno
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
2 weeks 6 days ago #14084 by Inferno
Hi,
I need to use SysCall unit to access extended attributes on macOS platform. I found this solution https://forum.lazarus.freepascal.org/index.php?topic=24096.0 but I cannot include SysCall unit as it appeares to be not available (Cannot find SysCall...). Any idea how to call do_syscall(syscall_nr_getxattr, TSysParam(path), TSysParam(name), TSysParam(value), TSysParam(size)); on macOS?

And second question - how to manipulate files and directories permissions, both:

POSIX ( https://man.openbsd.org/FreeBSD-11.1/getmode.3 ) and
ACL ( https://man.openbsd.org/FreeBSD-11.1/acl_set.3 ).

All these functions are the part of libc library in Unix system.

Best regards,
inferno

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
2 weeks 5 days ago - 2 weeks 5 days ago #14086 by Sternas Stefanos
Replied by Sternas Stefanos on topic using SysCall and manipulating file permissions on macOS
Thanks Sir
codetyphon/fpcsrc/rtl/unix/syscall.pp
is avalible only for
[Linux, Beos and FreeBSD] OSes

Line 197 of
codetyphon/fpcsrc/rtl/fpmake.pp

So, you can't use this unit to MacOS

PS: Your MacOS Ver ?

PilotLogic Architect and Core Programmer
Last edit: 2 weeks 5 days ago by Sternas Stefanos.

Please Log in or Create an account to join the conversation.

  • Inferno
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
2 weeks 4 days ago - 2 weeks 4 days ago #14095 by Inferno
Thank you for your reply Sternas! Currently I'm on macOS Mojave/10.14 nad CT6.9 but plan to move to on macOS Catalina/10.15, so only 64bit target. In the mean time I've dig a little and found that there is:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/syscall.h

In that file there are syscall codes specified to Darwin/macOS including those related to extended attributes:

#define SYS_getxattr 234
#define SYS_fgetxattr 235
#define SYS_setxattr 236
#define SYS_fsetxattr 237
#define SYS_removexattr 238
#define SYS_fremovexattr 239
#define SYS_listxattr 240
#define SYS_flistxattr 241


Also I've dig a little in /usr/local/codetyphon/fpcsrc/rtl/ and found that there is no syscall.pp and other included files for macOS. The declaratrions and implementations of do_syscall functions are in syscall.inc and syscallh.inc, but this is an asembler code :ohmy: It should be possible to call syscall() for macOS platform as this is unix based system and syscall() is available in (/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h). Any idea? Maybe it is possible to port syscall.pp and other *.inc files from FreeBSD to macOS?

According to file permissions I found some functions available in baseunix unit which is fortunetly available on macOS: www.freepascal.org/docs-html/rtl/baseunix/fpaccess.html , www.freepascal.org/docs-html/rtl/baseunix/fpfstat.html , www.freepascal.org/docs-html/rtl/baseunix/fpchmod.html , www.freepascal.org/docs-html/rtl/baseunix/fpchown.html . This functions work properly but use only POSIX and operates only with UID/GID. Any idea how to convert UID/GID to real names?

And another approach - running C code directly. I found this: ftp://ftp.freepascal.org/fpc/docs-pdf/CinFreePascal.pdf . What do you think?

Best regards,
Inferno
Last edit: 2 weeks 4 days ago by Inferno.

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
2 weeks 4 days ago #14097 by Sternas Stefanos
Replied by Sternas Stefanos on topic using SysCall and manipulating file permissions on macOS
Sir
MacOS is NOT FreeBSD.
MacOS has many security limitations in MacOS API.

My suggestion is:
1) macOS Catalina/10.15 + Lab CodeTyphon 7.00
2) Try to use FPC baseunix.pp functions

PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

  • Inferno
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
2 weeks 4 days ago #14098 by Inferno
Thank you for your suggestions Sternas :) As I mentioned baseunix allows only POSIX manipulation, no extended attributes and ACL. If I will find something I will post here.

BTW - I've tried to use KControls on macOS and cannot - the message occurs "Error: Error creating component: TKGrid". The same with TKDBGrid. The same behavior on CT6.9 and CT7.0. Any idea how to fix it?

Best regards,
Inferno

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
2 weeks 4 days ago #14101 by Sternas Stefanos
Replied by Sternas Stefanos on topic using SysCall and manipulating file permissions on macOS
We never test KControls on macOS
but we will now

PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

  • Inferno
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
2 weeks 3 days ago #14103 by Inferno
Hi Sternas,
I found this https://forum.lazarus.freepascal.org/index.php?topic=38170.0 but it is two years old case. I tried to create TKGrid in run time which causes access violation. Suppose it will be some incompatibility with Cocoa but KControls were designed to be cross platform and IDE compatible so it should be possible to fix. Let me know when you will find the solution. Thank you :)

Best regards,
Inferno

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
2 weeks 3 days ago - 2 weeks 2 days ago #14104 by Sternas Stefanos
Replied by Sternas Stefanos on topic using SysCall and manipulating file permissions on macOS
Sir
we test pl_KControls on MacOS 10.15 with LAB CT 7.00
-Typhon 7.0 r62296
-FPC 3.3.1 r43585
-Platform : x86_64-darwin-cocoa (beta)


First you must add pl_KControls to Typhon IDE.






Many components works OK, some other NOT.
Our work at first level, is to "port" KControls on MacOS and CodeTyphon,
in order to give KControls programmer(s) the " Programming Platform" to work on it.

So, someone must do the hard job: to find and solve the problems.


PilotLogic Architect and Core Programmer
Attachments:
Last edit: 2 weeks 2 days ago by Sternas Stefanos.

Please Log in or Create an account to join the conversation.