Re: Q: ESQL/C and SUID
Posted in 1998
Robert Schmittinger wrote: > I want to write a program, that connects to a database whith 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, wether 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? Been there, done that. Thanks to the excellent help of Jonathan Leffler, I finally found a way to do this. It's not pretty, though! It requires that the program belongs to root and has the s-bit set, which is something that may not be desirable due to security concerns. Before you connect to the database (important!), issue a "setuid" system call in your program to set the effective uid to the one you desire. Then the euid is used to connect to the database. HTH, Richard -- +--------------------------+------------------------------------------+ | Dr. Richard Spitz | INTERNET: spitz@ana.med.uni-muenchen.de | | EDV-Gruppe Anaesthesie | Tel : +49-89-7095-3413 | | Klinikum Grosshadern | FAX : +49-89-7095-8886 | | 81366 Munich, Germany | GSM : +49-172-8933578 | +--------------------------+------------------------------------------+