autofssrv_cmd.c revision 877b92e80bde510d5cd9f03dbf01e2bcf73ab072
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen Jakub Hrozek <jhrozek@redhat.com>
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen Copyright (C) 2012 Red Hat
aa797403d51ff047727b77d64532001d6b6cc21aTimo Sirainen Autofs responder: commands
05b7b8f14426b5fe5d016940eb5916033f0bc841Timo Sirainen This program is free software; you can redistribute it and/or modify
b6b9c99fefbbc662bd9a0006566133c4480bf0e8Timo Sirainen it under the terms of the GNU General Public License as published by
550d2fe097e95f12e8fa60ef52753ea7fe53d4eaTimo Sirainen the Free Software Foundation; either version 3 of the License, or
b6b9c99fefbbc662bd9a0006566133c4480bf0e8Timo Sirainen (at your option) any later version.
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen This program is distributed in the hope that it will be useful,
550d2fe097e95f12e8fa60ef52753ea7fe53d4eaTimo Sirainen but WITHOUT ANY WARRANTY; without even the implied warranty of
dff32d11a411a24f3b76003c1ae22c5a960f180eTimo Sirainen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
550d2fe097e95f12e8fa60ef52753ea7fe53d4eaTimo Sirainen GNU General Public License for more details.
eb209d12e3b1cfed564c35cf19fdb1bf7fcc6811Timo Sirainen You should have received a copy of the GNU General Public License
eb209d12e3b1cfed564c35cf19fdb1bf7fcc6811Timo Sirainen along with this program. If not, see <http://www.gnu.org/licenses/>.
8c2b4a45f17a5cb13bb01058ca37798cf48d91baTimo Sirainenstatic int autofs_cmd_send_error(struct autofs_cmd_ctx *cmdctx, int err)
b44033e45e9f48f8a6e1ac5905234fec5de6d6ccAki Tuomiautofs_cmd_send_empty(struct autofs_cmd_ctx *cmdctx)
c13fce16374a6fa8d127742c527498d38e777789Timo Sirainen return sss_cmd_send_empty(cmdctx->cctx, cmdctx);
c13fce16374a6fa8d127742c527498d38e777789Timo Sirainenautofs_cmd_done(struct autofs_cmd_ctx *cmdctx, int ret)
c13fce16374a6fa8d127742c527498d38e777789Timo Sirainen /* all fine, just return here */
c13fce16374a6fa8d127742c527498d38e777789Timo Sirainen /* async processing, just return here */
c13fce16374a6fa8d127742c527498d38e777789Timo Sirainen /* very bad error */
1b7cd57585d8c2f133dd612d2d5d9c775595659fTimo Sirainen return setent_add_ref(memctx, map_ctx, &map_ctx->reqs, req);
1b7cd57585d8c2f133dd612d2d5d9c775595659fTimo Sirainenautofs_setent_notify(struct autofs_map_ctx *map_ctx, errno_t ret)
1b7cd57585d8c2f133dd612d2d5d9c775595659fTimo Sirainen unsigned long mcount;
1b7cd57585d8c2f133dd612d2d5d9c775595659fTimo Sirainen unsigned long i;
5f5713d6468dca1acf3d350dd8a33057331f78c5Timo Sirainen for (i = 0; i < mcount; i++) {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEBUG(SSSDBG_MINOR_FAILURE, "Could not delete key from hash\n");
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainen *map = talloc_get_type(value.ptr, struct autofs_map_ctx);
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen } else if (hret == HASH_ERROR_KEY_NOT_FOUND) {
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen "Unexpected error reading from autofs map hash [%d][%s]\n",
58b8a301b7b36047f10a592751094fbed86d6f0cTimo Sirainenstatic int autofs_map_hash_remove (TALLOC_CTX *ctx);
89d6cd658eabf46e07e40037b0e641ed9be1a2a3Timo Sirainen map = talloc_get_type(item->value.ptr, struct autofs_map_ctx);
ece0a20249ce26208db3415ba2e79423678856f8Timo Sirainen DEBUG(SSSDBG_OP_FAILURE, "Invalid autofs map\n");
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen /* So that the destructor wouldn't attempt to remove the map from hash
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "Missing autofs map name.\n");
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen /* Add this entry to the hash table */
152db3f90f298b7fb2dbbd4276f0fc30a9bc30f6Timo Sirainen "Unable to add hash table entry for [%s]\n", key.str);
aa797403d51ff047727b77d64532001d6b6cc21aTimo Sirainen "Hash error [%d][%s]\n", hret, hash_error_string(hret));
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen talloc_set_destructor((TALLOC_CTX *) map, autofs_map_hash_remove);
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainen DEBUG(SSSDBG_TRACE_LIBS, "autofs map [%s] was already removed\n",
f5d82a4b87a9b17894e1869cfe8b1a90afbced59Timo Sirainen /* Remove the autofs map result object from the lookup table */
15ab2452b0220a115f4351ad9d7fd5ec70ae7966Timo Sirainen "Could not remove key from table! [%d][%s]\n",
bfef6891565ff9018ac92add6eae401e9352c657Timo Sirainenstatic struct tevent_req *
36e091dc733c6cd690c5aae6e411e41adb1eca73Timo Sirainenstatic errno_t setautomntent_recv(struct tevent_req *req);
36e091dc733c6cd690c5aae6e411e41adb1eca73Timo Sirainenstatic void sss_autofs_cmd_setautomntent_done(struct tevent_req *req);
36e091dc733c6cd690c5aae6e411e41adb1eca73Timo Sirainen/* FIXME - file a ticket to have per-responder private
15ab2452b0220a115f4351ad9d7fd5ec70ae7966Timo Sirainen * data instead of growing the cli_ctx structure */
15ab2452b0220a115f4351ad9d7fd5ec70ae7966Timo Sirainensss_autofs_cmd_setautomntent(struct cli_ctx *client)
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEBUG(SSSDBG_TRACE_INTERNAL, "sss_autofs_cmd_setautomntent\n");
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen cmdctx = talloc_zero(client, struct autofs_cmd_ctx);
e2fdcdb4ee53ab769123e27997713aaea34910e1Timo Sirainen sss_packet_get_body(client->creq->in, &body, &blen);
de92873c366becfaea1554642f89b9169d7955e2Timo Sirainen /* if not terminated fail */
c3a2a487e23a282e59254b82deb9344ed0306bb2Timo Sirainen /* If the body isn't valid UTF-8, fail */
if (!req) {
goto done;
done:
struct setautomntent_state {
char *mapname;
struct setautomntent_lookup_ctx {
bool returned_to_mainloop;
char *mapname;
static errno_t
void *pvt)
map);
if (!te) {
static errno_t
char *mapname,
static struct tevent_req *
const char *rawname,
char *domname;
if (!req) {
return NULL;
if (!dctx) {
goto fail;
goto fail;
if (domname) {
goto fail;
goto fail;
goto fail;
return req;
return req;
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
if (!lookup_ctx) {
goto fail;
goto fail;
return req;
goto fail;
return req;
goto fail;
return req;
fail:
return req;
static errno_t
char *mapname,
return ENOENT;
static errno_t
static errno_t
while (dom) {
return EIO;
return ret;
return ret;
return ENOENT;
return EAGAIN;
return ret;
return EIO;
return EOK;
if (!map) {
return ENOMEM;
return ENOMEM;
return ENOMEM;
return ENOENT;
static errno_t
SYSDB_CACHE_EXPIRE, 0);
return EOK;
goto error;
if (!req) {
goto error;
if(!cb_ctx) {
goto error;
return EAGAIN;
return ret;
return EOK;
char *err_msg;
&err_msg);
if (err_maj) {
static errno_t
return EOK;
static errno_t
static errno_t
size_t c = 0;
if (!cmdctx) {
return ENOMEM;
if (!actx) {
return EIO;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
done:
goto done;
goto done;
goto done;
done:
static errno_t
return ret;
goto done;
goto done;
nentries = 0;
for (i=0; i < stop; i++) {
cursor++;
nentries++;
rp = 0;
done:
return EOK;
static errno_t
const char *key;
const char *value;
return EINVAL;
return ret;
return EOK;
static errno_t
const char *key);
size_t c = 0;
if (!cmdctx) {
return ENOMEM;
if (!actx) {
return EIO;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
done:
goto done;
goto done;
goto done;
done:
static errno_t
const char *key)
size_t i;
const char *value;
return ret;
goto done;
goto done;
goto done;
rp = 0;
done:
return EOK;
return ret;
return EOK;
return autofs_cli_protocol_version;
return autofs_cmds;