diff options
author | Ken Raeburn <raeburn@mit.edu> | 2007-10-22 19:18:53 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@mit.edu> | 2007-10-22 19:18:53 +0000 |
commit | 3d8fa6bb4012296a53fe04e486a9157a2963b644 (patch) | |
tree | 7c0f5dcc658ebd75d758024a21097af95d616e05 /src/plugins/kdb/db2/kdb_db2.c | |
parent | 70e8d7a6c50bbdb547150eba0abdef46d93d5b71 (diff) | |
download | krb5-3d8fa6bb4012296a53fe04e486a9157a2963b644.zip krb5-3d8fa6bb4012296a53fe04e486a9157a2963b644.tar.gz krb5-3d8fa6bb4012296a53fe04e486a9157a2963b644.tar.bz2 |
Set close-on-exec flag in most places where file descriptors are
opened in our libraries (in case another application thread spawns a
new process) and in the KDC programs (in case a plugin library spawns
a new process).
Checked calls to: open fopen THREEPARAMOPEN mkstemp socket accept dup
dup2 pipe. In: util lib plugins kdc kadmin/server krb524.
The various programs are less critical than the libraries, as any
well-written plugin that spawns a new process should close all file
descriptors it doesn't need to communicate with the new process.
This approach also isn't bulletproof, as the call to set the
close-on-exec flag is necessarily a separate call from creating the
file descriptor, and the fork call could happen in between them. So
plugins should be careful regardless of this patch; it will only
reduce the window of potential lossage should a plugin be poorly
written. (AFAIK there are currently no plugins that spawn processes
where this would be a problem.)
Update dependencies.
ticket: 5561
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20143 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/plugins/kdb/db2/kdb_db2.c')
-rw-r--r-- | src/plugins/kdb/db2/kdb_db2.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/plugins/kdb/db2/kdb_db2.c b/src/plugins/kdb/db2/kdb_db2.c index bce6597..eda5274 100644 --- a/src/plugins/kdb/db2/kdb_db2.c +++ b/src/plugins/kdb/db2/kdb_db2.c @@ -1,7 +1,7 @@ /* * lib/kdb/kdb_db2.c * - * Copyright 1997,2006 by the Massachusetts Institute of Technology. + * Copyright 1997,2006,2007 by the Massachusetts Institute of Technology. * All Rights Reserved. * * Export of this software from the United States of America may @@ -332,6 +332,7 @@ krb5_db2_db_init(krb5_context context) goto err_out; } } + set_cloexec_fd(db_ctx->db_lf_file); db_ctx->db_inited++; if ((retval = krb5_db2_db_get_age(context, NULL, &db_ctx->db_lf_time))) @@ -754,6 +755,7 @@ destroy_file_suffix(char *dbname, char *suffix) free(filename); return errno; } + set_cloexec_fd(fd); /* fstat() will probably not fail unless using a remote filesystem * (which is inappropriate for the kerberos database) so this check * is mostly paranoia. */ @@ -1719,6 +1721,7 @@ krb5_db2_db_rename(context, from, to) retval = errno; goto errout; } + set_cloexec_fd(db_ctx->db_lf_file); db_ctx->db_inited = 1; |