From patchwork Mon Jun 20 22:01:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirish Pargaonkar X-Patchwork-Id: 898752 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5KLtGtT024567 for ; Mon, 20 Jun 2011 21:55:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755934Ab1FTVzE (ORCPT ); Mon, 20 Jun 2011 17:55:04 -0400 Received: from mail-yi0-f46.google.com ([209.85.218.46]:33496 "EHLO mail-yi0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755422Ab1FTVzC (ORCPT ); Mon, 20 Jun 2011 17:55:02 -0400 Received: by yia27 with SMTP id 27so2272008yia.19 for ; Mon, 20 Jun 2011 14:55:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=SNTD/Zv9ihvwuwzttWK0RD/EJTeY/VFW/Z+84L8NBVU=; b=tU2zr7gO64Yb+P3ukIvjZe/0GEcsPQa6ZczVVnwUWPKhUUj7G219nbih7ibxwe1rTj fqimInsjkqDJTuG/Xwks1g11FFtxN+5g64FuIVVIlJcifovRsKgJx0xM5gP546s+H9Dn HpYOGll6Qiq8LE+lXlpdL4PIzKIsSs/WvNgCs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=Yv4ax7kfWjR51NFhbwdISIzhjUe5ylqhs9ReTJa5sz3NWD939ues0fmjaPQL9RvKD5 V2PUC/GvceZihIIOOiO7cJaVK5f0UuE2oM2x/xXCCOYIDuA7PhE54B36Pr5H2kJghVIl B5u5L2ersIE1Z3bl5+KawNCLI5ymrpapBVGpY= Received: by 10.150.164.18 with SMTP id m18mr6387040ybe.231.1308606902104; Mon, 20 Jun 2011 14:55:02 -0700 (PDT) Received: from localhost ([32.97.110.58]) by mx.google.com with ESMTPS id f70sm1800523yhe.22.2011.06.20.14.55.00 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 20 Jun 2011 14:55:01 -0700 (PDT) From: shirishpargaonkar@gmail.com To: jlayton@redhat.com Cc: linux-cifs@vger.kernel.org, Shirish Pargaonkar Subject: [PATCH] cifs-utils: Add uid/gid to SID mapping functions Date: Mon, 20 Jun 2011 17:01:27 -0500 Message-Id: <1308607287-17061-1-git-send-email-shirishpargaonkar@gmail.com> X-Mailer: git-send-email 1.6.0.2 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 20 Jun 2011 21:55:17 +0000 (UTC) From: Shirish Pargaonkar Add functions to map a uid and gid to a SID. These functions are similar to SID to uid and gid mapping functions. Signed-off-by: Shirish Pargaonkar --- 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: