diff options
author | Shirish Pargaonkar <shirishpargaonkar@gmail.com> | 2011-10-19 14:18:12 -0400 |
---|---|---|
committer | Jeff Layton <jlayton@samba.org> | 2011-10-19 14:18:12 -0400 |
commit | 71c358b25c9bcd9b030a8f6844eecd42488e6724 (patch) | |
tree | b895c256a8d0b6e28996d1411c41e08b3618a60c | |
parent | e92709981e5d3e927a0ba823d7c94d7cf0940897 (diff) | |
download | cifs-utils-71c358b25c9bcd9b030a8f6844eecd42488e6724.tar.gz cifs-utils-71c358b25c9bcd9b030a8f6844eecd42488e6724.tar.bz2 cifs-utils-71c358b25c9bcd9b030a8f6844eecd42488e6724.zip |
cifs.idmap: Add uid/gid to SID mapping functions (try #3)
Add functions to map a uid and gid to a SID. These functions are
similar to SID to uid and gid mapping functions. A SID is what is
returned to the cifs module.
Signed-off-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
-rw-r--r-- | cifs.idmap.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/cifs.idmap.c b/cifs.idmap.c index 56edb58..80802d7 100644 --- a/cifs.idmap.c +++ b/cifs.idmap.c @@ -134,6 +134,43 @@ cifs_idmap(const key_serial_t key, const char *key_descr) goto cifs_idmap_ret; } + sidstr = strget(key_descr, "oi:"); + if (sidstr) { + uid = atoi(sidstr); + syslog(LOG_DEBUG, "SID: %s, uid: %d", sidstr, uid); + rc = wbcUidToSid(uid, &sid); + if (rc) + syslog(LOG_DEBUG, "uid %d to SID error: %d", uid, rc); + if (!rc) { /* SID has been mapped to a uid */ + rc = keyctl_instantiate(key, &sid, + sizeof(struct wbcDomainSid), 0); + if (rc) + syslog(LOG_ERR, "%s: key inst: %s", + __func__, strerror(errno)); + } + + goto cifs_idmap_ret; + } + + sidstr = strget(key_descr, "gi:"); + if (sidstr) { + gid = atoi(sidstr); + syslog(LOG_DEBUG, "SID: %s, gid: %d", sidstr, gid); + rc = wbcGidToSid(gid, &sid); + if (rc) + syslog(LOG_DEBUG, "gid %d to SID error: %d", gid, rc); + if (!rc) { /* SID has been mapped to a gid */ + rc = keyctl_instantiate(key, &sid, + sizeof(struct wbcDomainSid), 0); + if (rc) + syslog(LOG_ERR, "%s: key inst: %s", + __func__, strerror(errno)); + } + + goto cifs_idmap_ret; + } + + syslog(LOG_DEBUG, "Invalid key: %s", key_descr); cifs_idmap_ret: |