Units API.

See the Weblate's Web API documentation for detailed description of the API.

GET /api/units/100452/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "translation": "https://translate-dev.freebsd.org/api/translations/freebsd-doc/articles_pam/en/?format=api",
    "source": [
        "/*-\n * Copyright (c) 2002,2003 Networks Associates Technology, Inc.\n * All rights reserved.\n *\n * This software was developed for the FreeBSD Project by ThinkSec AS and\n * Network Associates Laboratories, the Security Research Division of\n * Network Associates, Inc.  under DARPA/SPAWAR contract N66001-01-C-8035\n * (\"CBOSS\"), as part of the DARPA CHATS research program.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. The name of the author may not be used to endorse or promote\n *    products derived from this software without specific prior written\n *    permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * $P4: //depot/projects/openpam/bin/su/su.c#10 $\n * $FreeBSD: head/en_US.ISO8859-1/articles/pam/su.c 38826 2012-05-17 19:12:14Z hrs $\n */\n\n#include <sys/param.h>\n#include <sys/wait.h>\n\n#include <err.h>\n#include <pwd.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <syslog.h>\n#include <unistd.h>\n\n#include <security/pam_appl.h>\n#include <security/openpam.h>\t/* for openpam_ttyconv() */\n\nextern char **environ;\n\nstatic pam_handle_t *pamh;\nstatic struct pam_conv pamc;\n\nstatic void\nusage(void)\n{\n\n\tfprintf(stderr, \"Usage: su [login [args]]\\n\");\n\texit(1);\n}\n\nint\nmain(int argc, char *argv[])\n{\n\tchar hostname[MAXHOSTNAMELEN];\n\tconst char *user, *tty;\n\tchar **args, **pam_envlist, **pam_env;\n\tstruct passwd *pwd;\n\tint o, pam_err, status;\n\tpid_t pid;\n\n\twhile ((o = getopt(argc, argv, \"h\")) != -1)\n\t\tswitch (o) {\n\t\tcase 'h':\n\t\tdefault:\n\t\t\tusage();\n\t\t}\n\n\targc -= optind;\n\targv += optind;\n\n\tif (argc > 0) {\n\t\tuser = *argv;\n\t\t--argc;\n\t\t++argv;\n\t} else {\n\t\tuser = \"root\";\n\t}\n\n\t/* initialize PAM */\n\tpamc.conv = &openpam_ttyconv;\n\tpam_start(\"su\", user, &pamc, &pamh);\n\n\t/* set some items */\n\tgethostname(hostname, sizeof(hostname));\n\tif ((pam_err = pam_set_item(pamh, PAM_RHOST, hostname)) != PAM_SUCCESS)\n\t\tgoto pamerr;\n\tuser = getlogin();\n\tif ((pam_err = pam_set_item(pamh, PAM_RUSER, user)) != PAM_SUCCESS)\n\t\tgoto pamerr;\n\ttty = ttyname(STDERR_FILENO);\n\tif ((pam_err = pam_set_item(pamh, PAM_TTY, tty)) != PAM_SUCCESS)\n\t\tgoto pamerr;\n\n\t/* authenticate the applicant */\n\tif ((pam_err = pam_authenticate(pamh, 0)) != PAM_SUCCESS)\n\t\tgoto pamerr;\n\tif ((pam_err = pam_acct_mgmt(pamh, 0)) == PAM_NEW_AUTHTOK_REQD)\n\t\tpam_err = pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK);\n\tif (pam_err != PAM_SUCCESS)\n\t\tgoto pamerr;\n\n\t/* establish the requested credentials */\n\tif ((pam_err = pam_setcred(pamh, PAM_ESTABLISH_CRED)) != PAM_SUCCESS)\n\t\tgoto pamerr;\n\n\t/* authentication succeeded; open a session */\n\tif ((pam_err = pam_open_session(pamh, 0)) != PAM_SUCCESS)\n\t\tgoto pamerr;\n\n\t/* get mapped user name; PAM may have changed it */\n\tpam_err = pam_get_item(pamh, PAM_USER, (const void **)&user);\n\tif (pam_err != PAM_SUCCESS || (pwd = getpwnam(user)) == NULL)\n\t\tgoto pamerr;\n\n\t/* export PAM environment */\n\tif ((pam_envlist = pam_getenvlist(pamh)) != NULL) {\n\t\tfor (pam_env = pam_envlist; *pam_env != NULL; ++pam_env) {\n\t\t\tputenv(*pam_env);\n\t\t\tfree(*pam_env);\n\t\t}\n\t\tfree(pam_envlist);\n\t}\n\n\t/* build argument list */\n\tif ((args = calloc(argc + 2, sizeof *args)) == NULL) {\n\t\twarn(\"calloc()\");\n\t\tgoto err;\n\t}\n\t*args = pwd->pw_shell;\n\tmemcpy(args + 1, argv, argc * sizeof *args);\n\n\t/* fork and exec */\n\tswitch ((pid = fork())) {\n\tcase -1:\n\t\twarn(\"fork()\");\n\t\tgoto err;\n\tcase 0:\n\t\t/* child: give up privs and start a shell */\n\n\t\t/* set uid and groups */\n\t\tif (initgroups(pwd->pw_name, pwd->pw_gid) == -1) {\n\t\t\twarn(\"initgroups()\");\n\t\t\t_exit(1);\n\t\t}\n\t\tif (setgid(pwd->pw_gid) == -1) {\n\t\t\twarn(\"setgid()\");\n\t\t\t_exit(1);\n\t\t}\n\t\tif (setuid(pwd->pw_uid) == -1) {\n\t\t\twarn(\"setuid()\");\n\t\t\t_exit(1);\n\t\t}\n\t\texecve(*args, args, environ);\n\t\twarn(\"execve()\");\n\t\t_exit(1);\n\tdefault:\n\t\t/* parent: wait for child to exit */\n\t\twaitpid(pid, &status, 0);\n\n\t\t/* close the session and release PAM resources */\n\t\tpam_err = pam_close_session(pamh, 0);\n\t\tpam_end(pamh, pam_err);\n\n\t\texit(WEXITSTATUS(status));\n\t}\n\npamerr:\n\tfprintf(stderr, \"Sorry\\n\");\nerr:\n\tpam_end(pamh, pam_err);\n\texit(1);\n}\n"
    ],
    "previous_source": "",
    "target": [
        "/*-\n * Copyright (c) 2002,2003 Networks Associates Technology, Inc.\n * All rights reserved.\n *\n * This software was developed for the FreeBSD Project by ThinkSec AS and\n * Network Associates Laboratories, the Security Research Division of\n * Network Associates, Inc.  under DARPA/SPAWAR contract N66001-01-C-8035\n * (\"CBOSS\"), as part of the DARPA CHATS research program.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. The name of the author may not be used to endorse or promote\n *    products derived from this software without specific prior written\n *    permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * $P4: //depot/projects/openpam/bin/su/su.c#10 $\n * $FreeBSD: head/en_US.ISO8859-1/articles/pam/su.c 38826 2012-05-17 19:12:14Z hrs $\n */\n\n#include <sys/param.h>\n#include <sys/wait.h>\n\n#include <err.h>\n#include <pwd.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <syslog.h>\n#include <unistd.h>\n\n#include <security/pam_appl.h>\n#include <security/openpam.h>\t/* for openpam_ttyconv() */\n\nextern char **environ;\n\nstatic pam_handle_t *pamh;\nstatic struct pam_conv pamc;\n\nstatic void\nusage(void)\n{\n\n\tfprintf(stderr, \"Usage: su [login [args]]\\n\");\n\texit(1);\n}\n\nint\nmain(int argc, char *argv[])\n{\n\tchar hostname[MAXHOSTNAMELEN];\n\tconst char *user, *tty;\n\tchar **args, **pam_envlist, **pam_env;\n\tstruct passwd *pwd;\n\tint o, pam_err, status;\n\tpid_t pid;\n\n\twhile ((o = getopt(argc, argv, \"h\")) != -1)\n\t\tswitch (o) {\n\t\tcase 'h':\n\t\tdefault:\n\t\t\tusage();\n\t\t}\n\n\targc -= optind;\n\targv += optind;\n\n\tif (argc > 0) {\n\t\tuser = *argv;\n\t\t--argc;\n\t\t++argv;\n\t} else {\n\t\tuser = \"root\";\n\t}\n\n\t/* initialize PAM */\n\tpamc.conv = &openpam_ttyconv;\n\tpam_start(\"su\", user, &pamc, &pamh);\n\n\t/* set some items */\n\tgethostname(hostname, sizeof(hostname));\n\tif ((pam_err = pam_set_item(pamh, PAM_RHOST, hostname)) != PAM_SUCCESS)\n\t\tgoto pamerr;\n\tuser = getlogin();\n\tif ((pam_err = pam_set_item(pamh, PAM_RUSER, user)) != PAM_SUCCESS)\n\t\tgoto pamerr;\n\ttty = ttyname(STDERR_FILENO);\n\tif ((pam_err = pam_set_item(pamh, PAM_TTY, tty)) != PAM_SUCCESS)\n\t\tgoto pamerr;\n\n\t/* authenticate the applicant */\n\tif ((pam_err = pam_authenticate(pamh, 0)) != PAM_SUCCESS)\n\t\tgoto pamerr;\n\tif ((pam_err = pam_acct_mgmt(pamh, 0)) == PAM_NEW_AUTHTOK_REQD)\n\t\tpam_err = pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK);\n\tif (pam_err != PAM_SUCCESS)\n\t\tgoto pamerr;\n\n\t/* establish the requested credentials */\n\tif ((pam_err = pam_setcred(pamh, PAM_ESTABLISH_CRED)) != PAM_SUCCESS)\n\t\tgoto pamerr;\n\n\t/* authentication succeeded; open a session */\n\tif ((pam_err = pam_open_session(pamh, 0)) != PAM_SUCCESS)\n\t\tgoto pamerr;\n\n\t/* get mapped user name; PAM may have changed it */\n\tpam_err = pam_get_item(pamh, PAM_USER, (const void **)&user);\n\tif (pam_err != PAM_SUCCESS || (pwd = getpwnam(user)) == NULL)\n\t\tgoto pamerr;\n\n\t/* export PAM environment */\n\tif ((pam_envlist = pam_getenvlist(pamh)) != NULL) {\n\t\tfor (pam_env = pam_envlist; *pam_env != NULL; ++pam_env) {\n\t\t\tputenv(*pam_env);\n\t\t\tfree(*pam_env);\n\t\t}\n\t\tfree(pam_envlist);\n\t}\n\n\t/* build argument list */\n\tif ((args = calloc(argc + 2, sizeof *args)) == NULL) {\n\t\twarn(\"calloc()\");\n\t\tgoto err;\n\t}\n\t*args = pwd->pw_shell;\n\tmemcpy(args + 1, argv, argc * sizeof *args);\n\n\t/* fork and exec */\n\tswitch ((pid = fork())) {\n\tcase -1:\n\t\twarn(\"fork()\");\n\t\tgoto err;\n\tcase 0:\n\t\t/* child: give up privs and start a shell */\n\n\t\t/* set uid and groups */\n\t\tif (initgroups(pwd->pw_name, pwd->pw_gid) == -1) {\n\t\t\twarn(\"initgroups()\");\n\t\t\t_exit(1);\n\t\t}\n\t\tif (setgid(pwd->pw_gid) == -1) {\n\t\t\twarn(\"setgid()\");\n\t\t\t_exit(1);\n\t\t}\n\t\tif (setuid(pwd->pw_uid) == -1) {\n\t\t\twarn(\"setuid()\");\n\t\t\t_exit(1);\n\t\t}\n\t\texecve(*args, args, environ);\n\t\twarn(\"execve()\");\n\t\t_exit(1);\n\tdefault:\n\t\t/* parent: wait for child to exit */\n\t\twaitpid(pid, &status, 0);\n\n\t\t/* close the session and release PAM resources */\n\t\tpam_err = pam_close_session(pamh, 0);\n\t\tpam_end(pamh, pam_err);\n\n\t\texit(WEXITSTATUS(status));\n\t}\n\npamerr:\n\tfprintf(stderr, \"Sorry\\n\");\nerr:\n\tpam_end(pamh, pam_err);\n\texit(1);\n}\n"
    ],
    "id_hash": -3345463723566291862,
    "content_hash": -3345463723566291862,
    "location": "article.translate.xml:1251",
    "context": "",
    "note": "(itstool) path: appendix/programlisting",
    "flags": "no-wrap",
    "labels": [],
    "state": 100,
    "fuzzy": false,
    "translated": true,
    "approved": false,
    "position": 225,
    "has_suggestion": false,
    "has_comment": false,
    "has_failing_check": true,
    "num_words": 713,
    "source_unit": "https://translate-dev.freebsd.org/api/units/100452/?format=api",
    "priority": 100,
    "id": 100452,
    "web_url": "https://translate-dev.freebsd.org/translate/freebsd-doc/articles_pam/en/?checksum=51928677ebe0246a",
    "url": "https://translate-dev.freebsd.org/api/units/100452/?format=api",
    "explanation": "",
    "extra_flags": "",
    "pending": false,
    "timestamp": "2019-10-20T12:13:59.412931Z"
}