summaryrefslogtreecommitdiffstats
path: root/xlators/features/access-control/src/access-control.c
diff options
context:
space:
mode:
authorGaurav <gaurav@gluster.com>2011-06-02 01:48:40 +0000
committerAnand Avati <avati@gluster.com>2011-06-08 11:18:55 -0700
commit43368cffd23b9dc4b1f98cf595b0d486b9e6dec9 (patch)
tree5f3bec1814a1d95c9653fce70680ddd59777f47d /xlators/features/access-control/src/access-control.c
parent9e1817126ff625633de9cb13bb9f4174919690a0 (diff)
Access-Control : Sticky bit validation for rename, unlink and rmdir.
Signed-off-by: Gaurav <gaurav@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2886 (No sticky bit validation in access control) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2886
Diffstat (limited to 'xlators/features/access-control/src/access-control.c')
-rw-r--r--xlators/features/access-control/src/access-control.c220
1 files changed, 197 insertions, 23 deletions
diff --git a/xlators/features/access-control/src/access-control.c b/xlators/features/access-control/src/access-control.c
index 92908791b..dc2305116 100644
--- a/xlators/features/access-control/src/access-control.c
+++ b/xlators/features/access-control/src/access-control.c
@@ -828,10 +828,8 @@ ac_unlink_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (op_ret == -1)
goto out;
- op_ret = ac_test_access (buf, frame->root->uid, frame->root->gid,
- frame->root->groups, frame->root->ngrps,
- ACCTEST_WRITE, ACCTEST_ANY, &op_errno);
- if (op_ret == -1) {
+ if (frame->root->uid != buf->ia_uid) {
+ op_ret = -1;
op_errno = EACCES;
goto out;
}
@@ -849,6 +847,48 @@ out:
return 0;
}
+int32_t
+ac_unlink_parent_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *buf)
+{
+ call_stub_t *stub = NULL;
+
+ stub = frame->local;
+ if (op_ret == -1)
+ goto out;
+
+ if (buf->ia_prot.sticky == 0) {
+ op_ret = ac_test_access (buf, frame->root->uid, frame->root->gid,
+ frame->root->groups, frame->root->ngrps,
+ ACCTEST_WRITE, ACCTEST_ANY, &op_errno);
+ if (op_ret == -1) {
+ op_errno = EACCES;
+ goto out;
+ }
+ } else {
+ if ((frame->root->uid == 0) ||
+ (frame->root->uid == buf->ia_uid))
+ goto access;
+
+ STACK_WIND (frame, ac_unlink_stat_cbk, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->stat, &stub->args.unlink.loc);
+ goto out;
+ }
+
+access:
+ stub = __get_frame_stub (frame);
+ call_resume (stub);
+out:
+ if (op_ret < 0) {
+ stub = __get_frame_stub (frame);
+ STACK_UNWIND_STRICT (unlink, frame, -1, op_errno, NULL, NULL);
+ if (stub)
+ call_stub_destroy (stub);
+ }
+
+ return 0;
+}
+
int32_t
ac_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc)
@@ -872,7 +912,7 @@ ac_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc)
if (ret < 0)
goto out;
- STACK_WIND (frame, ac_unlink_stat_cbk, FIRST_CHILD (this),
+ STACK_WIND (frame, ac_unlink_parent_stat_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->stat, &parentloc);
loc_wipe (&parentloc);
ret = 0;
@@ -911,10 +951,8 @@ ac_rmdir_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (op_ret == -1)
goto out;
- op_ret = ac_test_access (buf, frame->root->uid, frame->root->gid,
- frame->root->groups, frame->root->ngrps,
- ACCTEST_WRITE, ACCTEST_ANY, &op_errno);
- if (op_ret == -1) {
+ if (frame->root->uid != buf->ia_uid) {
+ op_ret = -1;
op_errno = EACCES;
goto out;
}
@@ -932,6 +970,48 @@ out:
return 0;
}
+int32_t
+ac_rmdir_parent_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *buf)
+{
+ call_stub_t *stub = NULL;
+
+ stub = frame->local;
+ if (op_ret == -1)
+ goto out;
+
+ if (buf->ia_prot.sticky == 0) {
+ op_ret = ac_test_access (buf, frame->root->uid, frame->root->gid,
+ frame->root->groups, frame->root->ngrps,
+ ACCTEST_WRITE, ACCTEST_ANY, &op_errno);
+ if (op_ret == -1) {
+ op_errno = EACCES;
+ goto out;
+ }
+ } else {
+ if ((frame->root->uid == 0) ||
+ (frame->root->uid == buf->ia_uid))
+ goto access;
+
+ STACK_WIND (frame, ac_rmdir_stat_cbk, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->stat, &stub->args.rmdir.loc);
+ goto out;
+ }
+
+access:
+ stub = __get_frame_stub (frame);
+ call_resume (stub);
+out:
+ if (op_ret < 0) {
+ stub = __get_frame_stub (frame);
+ STACK_UNWIND_STRICT (rmdir, frame, -1, op_errno, NULL, NULL);
+ if (stub)
+ call_stub_destroy (stub);
+ }
+
+ return 0;
+}
+
int
ac_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags)
@@ -955,7 +1035,7 @@ ac_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags)
if (ret < 0)
goto out;
- STACK_WIND (frame, ac_rmdir_stat_cbk, FIRST_CHILD (this),
+ STACK_WIND (frame, ac_rmdir_parent_stat_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->stat, &parentloc);
loc_wipe (&parentloc);
ret = 0;
@@ -1080,23 +1160,68 @@ ac_rename_dst_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
call_stub_t *stub = NULL;
stub = __get_frame_stub (frame);
+
+ if ((op_ret == -1) && (op_errno == ENOENT))
+ goto access;
+
if (op_ret == -1)
goto out;
- op_ret = ac_test_access (buf, frame->root->uid,
- frame->root->gid, frame->root->groups,
- frame->root->ngrps, ACCTEST_WRITE,
- ACCTEST_ANY, &op_errno);
- if (op_ret == -1) {
+ if (frame->root->uid == buf->ia_uid)
+ goto access;
+ else {
+ op_ret = -1;
op_errno = EACCES;
- goto out;
+ goto out;
+ }
+access:
+ call_resume (stub);
+out:
+ if (op_ret < 0) {
+ STACK_UNWIND_STRICT (rename, frame, -1, op_errno, NULL, NULL,
+ NULL, NULL, NULL);
+ if (stub)
+ call_stub_destroy (stub);
}
+ return 0;
+}
+int32_t
+ac_rename_dst_parent_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *buf)
+{
+ call_stub_t *stub = NULL;
+
+ stub = frame->local;
+ if (op_ret == -1)
+ goto out;
+
+ if (buf->ia_prot.sticky == 0) {
+ op_ret = ac_test_access (buf, frame->root->uid,
+ frame->root->gid, frame->root->groups,
+ frame->root->ngrps, ACCTEST_WRITE,
+ ACCTEST_ANY, &op_errno);
+ if (op_ret == -1) {
+ op_errno = EACCES;
+ goto out;
+ }
+ } else {
+ if ((frame->root->uid == 0) ||
+ (frame->root->uid == buf->ia_uid))
+ goto access;
+ STACK_WIND (frame, ac_rename_dst_stat_cbk, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->stat, &stub->args.rename.new);
+ goto out;
+ }
+
+access:
+ stub = __get_frame_stub (frame);
call_resume (stub);
out:
if (op_ret < 0) {
gf_log (this->name, GF_LOG_ERROR, "rename failed with error: %s",
strerror (op_errno));
+ stub = __get_frame_stub (frame);
STACK_UNWIND_STRICT (rename, frame, -1, op_errno, NULL, NULL,
NULL, NULL, NULL);
if (stub)
@@ -1118,11 +1243,8 @@ ac_rename_src_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (op_ret == -1)
goto out;
- op_ret = ac_test_access (buf, frame->root->uid,
- frame->root->gid, frame->root->groups,
- frame->root->ngrps, ACCTEST_WRITE,
- ACCTEST_ANY, &op_errno);
- if (op_ret == -1) {
+ if (buf->ia_uid != frame->root->uid) {
+ op_ret = -1;
op_errno = EACCES;
goto out;
}
@@ -1133,7 +1255,59 @@ ac_rename_src_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
- STACK_WIND (frame, ac_rename_dst_stat_cbk, FIRST_CHILD (this),
+ STACK_WIND (frame, ac_rename_dst_parent_stat_cbk, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->stat, &parentloc);
+ loc_wipe (&parentloc);
+
+out:
+ if (op_ret < 0) {
+ /* Erase the stored stub before unwinding. */
+ stub = __get_frame_stub (frame);
+ if (stub)
+ call_stub_destroy (stub);
+ STACK_UNWIND_STRICT (rename, frame, -1, op_errno, NULL, NULL,
+ NULL, NULL, NULL);
+ }
+ return 0;
+}
+
+int32_t
+ac_rename_src_parent_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *buf)
+{
+ call_stub_t *stub = NULL;
+ loc_t parentloc = {0, };
+
+ stub = frame->local;
+ if (op_ret == -1)
+ goto out;
+
+ if (buf->ia_prot.sticky == 0) {
+ op_ret = ac_test_access (buf, frame->root->uid,
+ frame->root->gid, frame->root->groups,
+ frame->root->ngrps, ACCTEST_WRITE,
+ ACCTEST_ANY, &op_errno);
+ if (op_ret == -1) {
+ op_errno = EACCES;
+ goto out;
+ }
+ } else {
+ if ((buf->ia_uid == frame->root->uid) ||
+ (frame->root->uid ==0))
+ goto access;
+ STACK_WIND (frame, ac_rename_src_stat_cbk, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->stat, &stub->args.rename.old);
+ goto out;
+ }
+
+access:
+ op_ret = ac_parent_loc_fill (&parentloc, &stub->args.rename.new);
+ if (op_ret < 0) {
+ op_errno = -EFAULT;
+ goto out;
+ }
+
+ STACK_WIND (frame, ac_rename_dst_parent_stat_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->stat, &parentloc);
loc_wipe (&parentloc);
@@ -1175,7 +1349,7 @@ ac_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc)
if (ret < 0)
goto out;
- STACK_WIND (frame, ac_rename_src_stat_cbk, FIRST_CHILD (this),
+ STACK_WIND (frame, ac_rename_src_parent_stat_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->stat, &parentloc);
loc_wipe (&parentloc);
ret = 0;
colspan='2'>14 years v3.3.0qa32commit af0eb165f6...Vijay Bellur14 years v3.3.0qa31commit c40b9975d0...Vijay Bellur14 years v3.3.0qa30commit d98c3e1934...Vijay Bellur14 years v3.3.0qa29commit 65c6e3706f...Anand Avati14 years v3.3.0qa28commit 212d739886...Vijay Bellur14 years v3.2.6p3commit 410b1092e6...Vijay Bellur14 years v3.2.6p2commit 5ce988633d...Vijay Bellur14 years v3.3.0qa27commit 152a0194e7...Vijay Bellur14 years v3.2.6commit fafd5c17c0...Vijay Bellur14 years v3.2.6qa6commit fafd5c17c0...Vijay Bellur14 years v3.2.6qa5commit e657569da2...Vijay Bellur14 years v3.3.0qa26commit f6a779ffc5...Vijay Bellur14 years v3.2.6qa4commit 8127a6f35e...Vijay Bellur14 years v3.3.0qa25commit 468768d280...Vijay Bellur14 years v3.3.0qa24commit 88c6c11813...Vijay Bellur14 years v3.3.0qa23commit 42cc043875...Vijay Bellur14 years v3.3.0qa22commit c8d47f056e...Vijay Bellur14 years v3.2.6qa3commit cd3ad588f2...Anand Avati14 years v3.2.6qa2commit fa580e9299...Anand Avati14 years v3.3.0qa21commit 83a3daf7c2...Vijay Bellur14 years v3.3.0qa20commit 0694749c3e...Vijay Bellur14 years v3.2.6qa1commit 1020a3dfe9...Anand Avati14 years v3.3.0qa19commit be003fbb3a...Vijay Bellur14 years v3.3.0qa18commit d7d9f3d400...Vijay Bellur14 years v3.3.0qa17commit 0074f20844...Vijay Bellur14 years v3.3.0qa16commit 7235e5b1af...Vijay Bellur14 years v3.3.0qa15commit 289c2902d6...Vijay Bellur14 years v3.2.5commit edf9551b38...Vijay Bellur14 years v3.2.5qa9commit edf9551b38...Vijay Bellur14 years v3.2.5qa8commit 252c9e5cf2...Vijay Bellur14 years v3.2.5qa7commit d2a05724a6...Vijay Bellur14 years v3.2.5qa6commit 51601b2bff...Vijay Bellur14 years v3.2.5qa5commit 8668da9744...Vijay Bellur14 years v3.2.5qa4commit bca358604d...Vijay Bellur14 years v3.2.5qa3commit 3b0eecb53f...Vijay Bellur14 years v3.2.5qa2commit 7dcc94cf1f...Vijay Bellur14 years v3.2.5qa1commit 449f31c8ae...Vijay Bellur14 years v3.3.0qa14commit 4235f7a74e...Vijay Bellur14 years v3.2.4commit da73b31942...Vijay Bellur14 years v3.3.0qa13commit 795c8996c1...Vijay Bellur14 years v3.2.4qa5commit 6c5d3e40a6...Vijay Bellur14 years v3.3.0qa12commit 16b7e3bf20...Vijay Bellur14 years v3.2.4qa4commit edd9461647...Vijay Bellur14 years v3.3.0qa11commit 7658047903...Vijay Bellur14 years v3.3.0qa10commit 4765dd1a1c...Vijay Bellur14 years v3.2.4qa3commit 9564e09e53...Vijay Bellur14 years v3.2.4qa2commit 0f9502d5eb...Vijay Bellur14 years v3.2.4qa1commit 6fe790ee35...Vijay Bellur14 years v3.3.0qa9commit b827cdb230...Vijay Bellur14 years v3.1.7commit a2739b842b...Vijay Bellur14 years v3.1.7qa4commit a2739b842b...Vijay Bellur14 years v3.1.7qa3commit f9fa468090...Vijay Bellur14 years v3.1.7qa2commit d120020fd5...Vijay Bellur14 years v3.1.7qa1commit 561bba7ae4...Vijay Bellur14 years v3.2.3commit 1acef91232...Vijay Bellur14 years v3.3beta2commit b827cdb230...Vijay Bellur14 years v3.3.0qa8commit b827cdb230...Vijay Bellur14 years v3.3.0qa7commit 601f5725a0...Vijay Bellur14 years v3.2.3qa6commit 1acef91232...Vijay Bellur14 years v3.3.0qa6commit b6e3e9c480...Vijay Bellur14 years v3.3.0qa5commit 5ace31ac21...Vijay Bellur14 years v3.2.3qa5commit 10f69943c4...Vijay Bellur14 years v3.3.0qa4commit 350ae611ca...Vijay Bellur15 years v3.2.3qa4commit 0564d1198b...Vijay Bellur15 years v3.2.3qa3commit 2f53b7857c...Vijay Bellur15 years v3.3.0qa3commit 6073fc29bf...Vijay Bellur15 years v3.3.0qa2commit a0071bdf2a...Vijay Bellur15 years v3.1.6commit 98a487f842...Vijay Bellur15 years v3.1.6qa8commit ef517191c5...Vijay Bellur15 years v3.3.0qa1commit 1b5a860f15...Vijay Bellur15 years v3.1.6qa7commit 05e3dcc9b1...Vijay Bellur15 years v3.2.3qa1commit 62adb4d1c2...Vijay Bellur15 years v3.1.6qa6commit c92f45c742...Anand Avati15 years v3.1.6qa5commit 0c01d96a06...Vijay Bellur15 years v3.1.6qa4commit dfc317a77f...Anand Avati15 years v3.1.6qa3commit 967199adb1...Anand Avati15 years v3.1.6qa2commit 7382534ac1...Anand Avati15 years v3.3beta1commit fd60df8798...Anand Avati15 years v3.2.2commit c82a9d438b...Anand Avati15 years v3.2.2qa8commit c82a9d438b...Anand Avati15 years v3.1.6qa1commit 0c9648c1a0...Anand Avati15 years v3.2.2qa7commit 972c4a3c34...Anand Avati15 years v3.2.2qa5commit 7685cec583...Anand Avati15 years v3.2.2qa4commit 817bda650c...Anand Avati15 years v3.2.2qa3commit 1b01b64894...Anand Avati15 years v3.2.2qa2commit 5c20eb3bbf...Vijay Bellur15 years v3.2.2qa1commit 6ca8604204...Anand Avati15 years v3.1.5commit a64d1a8157...Anand Avati15 years v3.1.5qa4commit a64d1a8157...Vijay Bellur15 years v3.1.5qa3commit 5bcb4ddca3...Anand Avati15 years v3.1.5qa2commit 25da481bc5...Anand Avati15 years v3.2.1commit c5321286e5...Anand Avati15 years v3.2.1qa5commit c5321286e5...Anand Avati15 years v3.2.1qa4commit 8dee45b3a7...Anand Avati15 years v3.2.1qa3commit c51b2f7c6c...Anand Avati15 years v3.2.1qa2commit 05c4dced82...Anand Avati15 years v3.2.1qa1commit ef39bf9d23...Anand Avati15 years v3.1.5qa1commit 5f1efbc32d...Vijay Bellur15 years v3.0.8commit ee744e0908...Vijay Bellur15 years v3.0.8qa1commit ee744e0908...Vijay Bellur15 years v3.2.0commit 77f485dc30...Anand Avati15 years branchpoint-3.2commit 1f06da6875...Anand Avati15 years v3.2.0qa16commit 625f779dba...Anand Avati15 years v3.2.0qa15commit b5848ed21b...Anand Avati15 years v3.2.0qa14commit 72b57e311f...Anand Avati15 years v3.2.0qa13commit da66edbe92...Vijay Bellur15 years v3.2.0qa12commit 1c5706c43d...Anand Avati15 years v3.2.0qa11commit 902478bf9e...Anand Avati15 years v3.1.4commit 7b368061ea...Anand Vishweshwaran Avati15 years v3.2.0qa10commit 6db2b422f0...Vijay Bellur15 years v3.1.4qa3commit 7b368061ea...Vijay Bellur15 years v3.2.0qa9commit 56814fefa0...Vijay Bellur15 years v3.2.0qa8commit 35dea20e40...Vijay Bellur15 years v3.1.4qa2commit 2b55a49045...Vijay Bellur15 years v3.2.0qa7commit f338193a70...Vijay Bellur15 years v3.2.0qa6commit 498dbbc506...Vijay Bellur15 years v3.2.0qa5commit 408a2b0298...Vijay Bellur15 years v3.1.3solariscommit 9c0d73d37b...Anand V. Avati15 years v3.2.0qa4commit bd132d8e41...Vijay Bellur15 years v3.1.3commit 1641d8bb4c...Vijay Bellur15 years v3.1.3qa8commit c549807c23...Vijay Bellur15 years v3.1.3qa7commit 5017098718...Vijay Bellur15 years v3.1.3qa6commit 93845ea7cc...Vijay Bellur15 years v3.1.3qa5commit cad088fe3a...Vijay Bellur15 years v3.1.3qa3commit 5b909c83de...Vijay Bellur15 years v3.1.3qa1commit b99e0e0678...Vijay Bellur15 years v3.1.2commit f2a067c4fe...Vijay Bellur15 years v3.0.7commit 6da4cc87ff...Anand V. Avati15 years v3.1.1commit 69a62d2a6d...Anand V. Avati15 years v3.0.6commit 5cbc81a8d3...Vijay Bellur15 years v3.0.6rc1commit ef4005be3a...Vijay Bellur15 years v3.1.0commit 6e6b4b4fd0...Vijay Bellur15 years v3.1.0qa9commit d13ddaf872...Anand V. Avati15 years v3.1.0qa8commit df4a7d7576...Anand V. Avati15 years v3.1.0prealpha4commit 12e997d863...Anand V. Avati16 years v3.1.0prealpha3commit f51252fa0d...Anand V. Avati16 years v3.1.0prealpha2commit 03df087149...Anand V. Avati16 years v3.1.0prealpha1commit 7e6b5454ad...Anand V. Avati16 years v3.1.0qa7commit ab72e06f7b...Anand V. Avati16 years v3.1.0qa6commit 0ec245abd6...Anand V. Avati16 years v3.1.0qa5commit 9349f559dc...Anand V. Avati16 years v3.1.0qa3commit 543f9ef575...Anand V. Avati16 years v3.1.0qa2commit 931a59e2b9...Anand V. Avati16 years v3.0.5commit 002d35bfb1...Anand V. Avati16 years v3.0.4commit aaeddc5084...Anand V. Avati16 years v3.0.3commit 029062c103...Anand V. Avati16 years v3.0.2commit 15043b6d97...Anand V. Avati16 years v3.0.1commit 4c20b5377e...Anand V. Avati16 years v2.0.9commit 7e1ba386dd...Anand V. Avati16 years v3.0.0commit 8379edd978...Anand V. Avati16 years v2.0.8commit 1a53a5a4bf...Anand V. Avati16 years v2.0.7commit 7ba890140f...Anand V. Avati16 years v2.0.6commit 8dfdde57b3...Anand V. Avati17 years v2.0.5commit 683fda4bf0...Anand V. Avati17 years v2.0.4commit 55f476455c...Anand V. Avati17 years v2.0.3commit b470684cbf...Anand V. Avati17 years tag-release-2.0commit 4d4cfc6e45...Anand V. Avati17 years 2.0.0commit 7b2e459db6...Anand V. Avati17 years 2.0.1commit 5c1d9108c1...Anand V. Avati17 years