Fix SSSD Config

This commit is contained in:
Kyrylo Gliebov 2018-10-09 18:39:21 +02:00
parent 75e3f0f4d3
commit 2fe77ec1da

View file

@ -350,6 +350,7 @@ class SssdConfig extends React.Component {
this.handleSubmit = this.handleSubmit.bind(this);
this.handleInputChange = this.handleInputChange.bind(this);
this.setConfig = this.setConfig.bind(this);
this.confSave = this.confSave.bind(this);
this.file = null;
this.state = {
scope: "",
@ -359,6 +360,19 @@ class SssdConfig extends React.Component {
};
}
confSave(obj) {
this.setState({submitting:"block"});
this.file.replace(obj).done(() => {
cockpit.spawn(["chmod", "600", "/etc/sssd/conf.d/sssd-session-recording.conf"], { "superuser": "require" }).done(() => {
cockpit.spawn(["systemctl", "restart", "sssd"], { "superuser": "require" }).done(() => {
this.setState({submitting:"none"});
})
.fail((data) => console.log(data));
})
.fail((data) => console.log(data));
});
}
handleInputChange(e) {
const value = e.target.type === 'checkbox' ? e.target.checked : e.target.value;
const name = e.target.name;
@ -368,9 +382,16 @@ class SssdConfig extends React.Component {
}
setConfig(data) {
if (data === null) {
const obj = {};
obj.session_recording = {};
obj.session_recording.scope = "none";
this.confSave(obj);
} else {
const config = {...data['session_recording']};
this.setState(config);
}
}
componentWillMount() {
let syntax_object = {
@ -385,7 +406,7 @@ class SssdConfig extends React.Component {
let promise = this.file.read();
promise.done(this.setConfig);
promise.done(() => this.file.watch(this.setConfig));
promise.fail(function(error) {
console.log(error);
@ -393,20 +414,12 @@ class SssdConfig extends React.Component {
}
handleSubmit(e) {
this.setState({submitting:"block"});
const obj = {};
obj.session_recording = {};
obj.session_recording.scope = this.state.scope;
obj.session_recording.users = this.state.users;
obj.session_recording.groups = this.state.groups;
let _this = this;
this.file.replace(obj).done(function() {
_this.setState({submitting:"none"});
})
.fail(function(error) {
console.log(error);
});
this.confSave(obj);
e.preventDefault();
}