Creating an NSS module
Hello:
I'm creating an NSS module for the passwd and group databases. I
implemented the following functions:
nss_status _nss_authon_setgrent()nss_status _nss_authon_endgrent()nss_status _nss_authon_getgrent_r (group * gr, char * buffer, size_t buflen, int * errnop)nss_status _nss_authon_getgrnam_r (const char * name, struct group * gr, char * buffer, size_t buflen, int * errnop)nss_status _nss_authon_getgrgid_r (const gid_t gid, struct group * gr, char * buffer, size_t buflen, int *errnop)
nss_status _nss_authon_setpwent()nss_status _nss_authon_endpwent()nss_status _nss_authon_getpwent_r (passwd * pw, char * buffer, size_t buflen, int * errnop)nss_status _nss_authon_getpwnam_r (const char * name, struct passwd * result, char * buffer, size_t buflen, int * errnop) nss_status _nss_authon_getpwuid_r (uid_t uid, passwd * result, char * buffer, size_t buflen, int * errnop)
The libc functions getgrent(), getgrnam(), getgrgid() and the finger command work, but the groups command doesn't and also the chgrp doesn't work for an user other than root. Any ideas on what happens? Am I missing some function?
Thanks,
Darío
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Darío Mariani
I'm creating an NSS module for the passwd and group databases. I
implemented the following functions:
[snip]
Quoted 4 lines
The libc functions
getgrent(),getgrnam(),getgrgid()and the finger command work, but the groups command doesn't and also the chgrp doesn't work for an user other than root. Any ideas on what happens? Am I missing some function?
I suspect that the problem is that you haven't logged in using the new groups.
The "id" command (used by the "groups" script) lists the supplementary GIDs of the current process. Similarly, the chgrp program uses the chown() system call to change a file's group; this insists that the new group is among the process' supplementary GIDs.
The supplementary GID's are set upon login (usually via the initgroups() libc function), and are inherited by child processes. The initgroups() function uses the setgroups() system call to set the process' supplementary GIDs as defined in the groups database. The setgroups() system call requires root privilege, so ordinary programs can't use it.
Changing the groups database (whether you change the data directly or, as in this case, change the mechanism by which it is obtained) will not affect the supplementary GIDs of any existing process. You will have to "log in" (whether via login, telnetd/sshd, xdm etc) in order for any changes in the groups database to take effect for authentication purposes.
OTOH, programs which use the groups database directly (i.e. the getgr*() functions) will reflect any changes immediately.
Signature · 5 lines
Glynn Clements <[email protected]> - To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Interprocess communication through stdin
Hello:
I'm implementing a program that spawns a child process. I was
wondering if instead of creating a pipe for interprocess communication is there any way to send data to the child by its stdin. The problem is that this child process is a program that accepts input from the stdin and I do not want modify it or have a named pipe redirected to its stdin.
Thanks,
Darío
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Interprocess communication through stdin
Quoted 5 lines · Darío Mariani
I'm implementing a program that spawns a child process. I was
wondering if instead of creating a pipe for interprocess communication is there any way to send data to the child by its stdin. The problem is that this child process is a program that accepts input from the stdin and I do not want modify it or have a named pipe redirected to its stdin.
Connect an unnamed pipe to the child's stdin:
int fds[2];
pid_t pid;
pipe(fds);
pid = fork();
if (pid > 0)
{
/* parent */
close(fds[0]);
}
else
{
/* child */
close(fds[1]);
dup2(fds[0], STDIN_FILENO);
close(fds[0]);
execl(prog, arg1, arg2, NULL);
}
/* write() to fds[1] to send data to child */[Error checking omitted for brevity.]
Signature · 5 lines
Glynn Clements <[email protected]> - To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
MIME library
In reply to Glynn ClementsHello:
Does anyone know of a MIME library that's more or less well
documented and has a free license (GPL, BSD, etc.)?
Thanks,
Darío
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html