RE: ESQL/C and SUID
Posted in 1998
---------- From: Robert Schmittinger[SMTP:uzs426@ibm.rhrz.uni-bonn.de] Sent: Wednesday, April 15, 1998 10:47 AM I want to write a program, that connects to a database with a specific userid. So i wrote an esql/c-program and set the s-bit (i don't want to include the password of the user in the program...). The problem is, that the esql/c program does not care, whether the s-bit is set or not. Is there any option, that forces an esql/c-program to connect to the database with the effective userid instead of the real userid? JL: Yes, assuming you are not using 5.x or earlier software. EXEC SQL CONNECT TO 'database@server' AS 'conn-name' USER 'me' USING 'password'; You cannot omit the USING clause if you give the USER clause. You can use string variables in place of any of the strings, and how you set those strings up is your business. You might want to try 'getpwuid(geteuid())' to get the user name for the effective UID (SUID); getting the password will be more problematic. Use the CONNECT instead of the DATABASE statement. The reason why SUID doesn't work has been explained in the long distant past on this group, but we're talking about 3 years ago, or maybe more. Anyway, under 5.x and earlier Informix systems, the application forked and execed an engine process. The engine was SUID root, SGID informix, and this effectively overrode the SUID-ness of the application. The real UID is inherited by the engine, and the effective UID was root; the real GID is inherited, and the effective GID was informix. So, when the engine looked to see who it was working for, it only knew about the real UID and GID and was not aware that the application was ever running set-anything. Yours, Jonathan Leffler (jleffler@visa.com) #include <bother.ms-exchange.h>