bash脚本中的kinit don' t使用php exec函数

发布于 2025-01-30 18:40:24 字数 959 浏览 3 评论 0原文

我有一个问题,我已经无法解决几个星期。 我创建了一个注册页面,该页面使用PHP语言将用户,密码和数据库中的其他元素放在数据库中。 我将Freeipa用于Kerberos身份验证/LDAP/NTP。

我只想在数据库中注册后在freeipa中创建用户,

因为当用户在所有验证和capcha之后签署时,我启动了带有PHP的exec函数的bash脚本。 这个bash脚本非常简单,chmod是700,带有所有者root:

#!/bin/bash
username="$1"
kinit -k -t /tmp/keytab manageuser@MYDOMAIN

ipa user-add $username --first $username --last $username --homedir /app/$username --shell /usr/sbin/nologin

我的键盘:

-rw------- 1 root root  160 mai   20 17:19 keytab

我在php中启动此bash脚本

$cmd = "sudo ../script $username";
exec($cmd, $output);
print_r($output);

,当然,apache用户在sudoer文件中仅用于此脚本,

我创建了一个用户“ manageuser “在freeipa中,管理用户的角色,以创建用户。

当我在终端运行时,此脚本可以工作,并且用户是在freeipa中创建的,但是当 PHP的EXEC函数启动脚本时,它不会创建用户

我的印象是 kinit不适用于PHP Exec 功能,为什么?

预先感谢您的帮助

I have a problem that I have not been able to solve for several weeks.
I created a registration page that uses the php language to put the user, password and other elements in the database.
I use freeipa for kerberos authentication/LDAP/NTP.

I just want to create the user in freeipa after the registration in the database

For that i launch a bash script with the exec function of php when a user signs up after all the verifications and the capcha ....
This bash script is very simple and chmod is 700 with the owner root:

#!/bin/bash
username="$1"
kinit -k -t /tmp/keytab manageuser@MYDOMAIN

ipa user-add $username --first $username --last $username --homedir /app/$username --shell /usr/sbin/nologin

My keytab:

-rw------- 1 root root  160 mai   20 17:19 keytab

I launch this bash script in php

$cmd = "sudo ../script $username";
exec($cmd, $output);
print_r($output);

Of course the apache user is in the sudoer file for only this script

I created a user "manageuser" in FREEIPA with the manage user's role, in order to create the users.

This script works when I run in a terminal, and the user is created in freeipa but when the exec function of php launches the script it does not create the user.

I have the impression that kinit does not work with php exec function, why ?

Thank you in advance for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文