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.handleSubmit = this.handleSubmit.bind(this);
this.handleInputChange = this.handleInputChange.bind(this); this.handleInputChange = this.handleInputChange.bind(this);
this.setConfig = this.setConfig.bind(this); this.setConfig = this.setConfig.bind(this);
this.confSave = this.confSave.bind(this);
this.file = null; this.file = null;
this.state = { this.state = {
scope: "", 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) { handleInputChange(e) {
const value = e.target.type === 'checkbox' ? e.target.checked : e.target.value; const value = e.target.type === 'checkbox' ? e.target.checked : e.target.value;
const name = e.target.name; const name = e.target.name;
@ -368,8 +382,15 @@ class SssdConfig extends React.Component {
} }
setConfig(data) { setConfig(data) {
const config = {...data['session_recording']}; if (data === null) {
this.setState(config); const obj = {};
obj.session_recording = {};
obj.session_recording.scope = "none";
this.confSave(obj);
} else {
const config = {...data['session_recording']};
this.setState(config);
}
} }
componentWillMount() { componentWillMount() {
@ -385,7 +406,7 @@ class SssdConfig extends React.Component {
let promise = this.file.read(); let promise = this.file.read();
promise.done(this.setConfig); promise.done(() => this.file.watch(this.setConfig));
promise.fail(function(error) { promise.fail(function(error) {
console.log(error); console.log(error);
@ -393,20 +414,12 @@ class SssdConfig extends React.Component {
} }
handleSubmit(e) { handleSubmit(e) {
this.setState({submitting:"block"});
const obj = {}; const obj = {};
obj.session_recording = {}; obj.session_recording = {};
obj.session_recording.scope = this.state.scope; obj.session_recording.scope = this.state.scope;
obj.session_recording.users = this.state.users; obj.session_recording.users = this.state.users;
obj.session_recording.groups = this.state.groups; obj.session_recording.groups = this.state.groups;
this.confSave(obj);
let _this = this;
this.file.replace(obj).done(function() {
_this.setState({submitting:"none"});
})
.fail(function(error) {
console.log(error);
});
e.preventDefault(); e.preventDefault();
} }