From fbffd35c31224f202a5fba174ef6b4047f4eb919 Mon Sep 17 00:00:00 2001 From: Kurt Hindenburg Date: Tue, 15 Apr 2014 11:16:03 -0400 Subject: [PATCH] Check return value of KDE::chmod --- src/Pty.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Pty.cpp b/src/Pty.cpp index 973a5880..39294749 100644 --- a/src/Pty.cpp +++ b/src/Pty.cpp @@ -262,10 +262,15 @@ void Pty::setWriteable(bool writeable) { KDE_struct_stat sbuf; KDE::stat(pty()->ttyName(), &sbuf); - if (writeable) - KDE::chmod(pty()->ttyName(), sbuf.st_mode | S_IWGRP); - else - KDE::chmod(pty()->ttyName(), sbuf.st_mode & ~(S_IWGRP | S_IWOTH)); + if (writeable) { + if (KDE::chmod(pty()->ttyName(), sbuf.st_mode | S_IWGRP) < 0) { + kWarning() << "Could not set writeable on "<ttyName(); + } + } else { + if (KDE::chmod(pty()->ttyName(), sbuf.st_mode & ~(S_IWGRP | S_IWOTH)) < 0) { + kWarning() << "Could not unset writeable on "<ttyName(); + } + } } void Pty::closePty()