Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-01

SetUid

8 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Balázs Csaba

Hello masters!

I am new on maillist. I have got a question. A cannot find function called setuid() like in c++. In the source of compiler/units a have found a section where the linux like function declared. There is a contant called "syscall_nr_setuid", but it is NOT used in any function. A can declare a setuid function but i do not know which registers are user int this function.
How can I switch to a low-level user (not root) after a fork() Can somebody help me?

Regards!
Balázs Csaba

Marco van de Voort
to Balázs Csaba
Show quoted text 9 lines
I am new on maillist. I have got a question. A cannot find function called setuid() like in c++. In the source of compiler/units a have found a section where the linux like function declared. There is a contant called "syscall_nr_setuid", but it is NOT used in any function. A can declare a setuid function but i do not know which registers are user int this function.

First argument in reg2 and so on. (for linux), e.g.

type uid_t=longint;
Function Sys_SetUid(uid:uid_t);
var
  regs : SysCallregs;
begin
  regs.reg2:=uid;
  Sys_setuid:=SysCall(SysCall_nr_setuid,regs);
end;
Marco van de Voort
to Balázs Csaba: Hello masters! I am new on maillist. I have got a question. A cannot find function called…
Show quoted text 8 lines
I am new on maillist. I have got a question. A cannot find function called setuid() like in c++. In the source of compiler/units a have found a section where the linux like function declared. There is a contant called "syscall_nr_setuid", but it is NOT used in any function. A can declare a setuid function but i do not know which registers are user int this function. How can I switch to a low-level user (not root) after a fork() Can somebody help me?

Note that that last one is untested, since I don't have Linux myself, and don't have root rights on the remote system I do some linux testing now and then.

Marco van de Voort
to Anton Tichawa: hello, csaba! here you are: <quote> // ... uses Linux; // ... function SetUID(UID:…
Show quoted text 22 lines
here you are: <quote> // ... uses Linux; // ... function SetUID(UID: Longint): Longint; var Regs: SysCallRegs; begin Regs.Reg2 := UID; SetUID := SysCall(SysCall_nr_getuid, Regs); end; //... </quote> written by me some months ago. a question to the fpc development team: i'm slowly getting paranoid, because access to hw, i/o and system seems to vanish as the years pass. what is the exact reason that setuid has not been implemented or wrapped in fpc?

None. There pretty much was an initial FPC port to Linux to get everything working, and after that functions were added on demand only. Specially because it changes often, and there is/was no decent way to autogenerate them.

I'm working on improving this in 1.1, and also separate the more portable from the more unportable functions there.

Michael Van Canneyt
to Anton Tichawa: hello, csaba! here you are: <quote> // ... uses Linux; // ... function SetUID(UID:…
Anton Tichawa wrote 24 lines
hello, csaba! here you are: <quote> // ... uses Linux; // ... function SetUID(UID: Longint): Longint; var Regs: SysCallRegs; begin Regs.Reg2 := UID; SetUID := SysCall(SysCall_nr_getuid, Regs); end; //... </quote> written by me some months ago. a question to the fpc development team: i'm slowly getting paranoid, because access to hw, i/o and system seems to vanish as the years pass. what is the exact reason that setuid has not been implemented or wrapped in fpc?

No particular reason. It wasn't needed at the time of the linux port It is (or should be) implemented in the new 1.1 series.

Michael.

Marco van de Voort
to Michael Van Canneyt
Show quoted text 15 lines
On Fri, 24 Jan 2003, Anton Tichawa wrote: > Regs.Reg2 := UID; > SetUID := SysCall(SysCall_nr_getuid, Regs); > end; > //... > > written by me some months ago. > > a question to the fpc development team: i'm slowly getting paranoid, because > access to hw, i/o and system seems to vanish as the years pass. what is the > exact reason that setuid has not been implemented or wrapped in fpc? No particular reason. It wasn't needed at the time of the linux port It is (or should be) implemented in the new 1.1 series.

It is, unit baseunix (which also works for *BSD).

Anton Tichawa
to Balázs Csaba: Hello masters! I am new on maillist. I have got a question. A cannot find function called…

hello, csaba!

here you are:

<quote>
// ...
uses
  Linux;
// ...
function SetUID(UID: Longint): Longint;
var
  Regs: SysCallRegs;
begin
  Regs.Reg2 := UID;
  SetUID := SysCall(SysCall_nr_getuid, Regs);
end;
//...
</quote>

written by me some months ago.

a question to the fpc development team: i'm slowly getting paranoid, because access to hw, i/o and system seems to vanish as the years pass. what is the exact reason that setuid has not been implemented or wrapped in fpc?

anton.

Balázs Csaba wrote 17 lines
Hello masters! I am new on maillist. I have got a question. A cannot find function called setuid() like in c++. In the source of compiler/units a have found a section where the linux like function declared. There is a contant called "syscall_nr_setuid", but it is NOT used in any function. A can declare a setuid function but i do not know which registers are user int this function. How can I switch to a low-level user (not root) after a fork() Can somebody help me? Regards! Balázs Csaba _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

----------

"Adas Methode war, wie sich zeigen wird, Tagträume in offenbar korrekte Berechnungen einzuweben."

Doris Langley Moore: Ada, Countess of Lovelace (London 1977).

----------

Anton Tichawa
Volkertstrasse 19 / 20
A-1020 Wien
phone: +43 1 218 97 59
mobil: +43 664 52 07 907
email:

----------

Anton Tichawa
to Michael Van Canneyt: No particular reason. It wasn't needed at the time of the linux port It is (or should be)…

hello, list!

Michael Van Canneyt wrote
No particular reason. It wasn't needed at the time of the linux port It is (or should be) implemented in the new 1.1 series.

thanks .. this makes me feel better. but isn't it strange that google finds not a single document containing syscall_nr_setuid? sorry if off-topic.

my example of setuid contains a typing error: the argument 'syscall_nr_getuid' should read 'syscall_nr_setuid'.

anton.

----------

"Adas Methode war, wie sich zeigen wird, Tagträume in offenbar korrekte Berechnungen einzuweben."

Doris Langley Moore: Ada, Countess of Lovelace (London 1977).

----------

Anton Tichawa
Volkertstrasse 19 / 20
A-1020 Wien
mobil: +43 664 52 07 907
email:

----------