• R/O
  • HTTP
  • SSH
  • HTTPS

alterlinux-calamares: Commit

GitHubのミラーです
https://github.com/FascodeNet/alterlinux-calamares


Commit MetaInfo

Revision329bd36929efe96ded9f4935fbde1da2ce3a4dba (tree)
Time2019-04-15 23:59:57
AuthorAdriaan de Groot <groot@kde....>
CommiterAdriaan de Groot

Log Message

[libcalamares] Sanitize logging

Change Summary

Incremental Difference

--- a/src/libcalamares/utils/CalamaresUtilsSystem.cpp
+++ b/src/libcalamares/utils/CalamaresUtilsSystem.cpp
@@ -38,6 +38,41 @@
3838 #include <sys/sysctl.h>
3939 #endif
4040
41+/** @brief When logging commands, don't log everything.
42+ *
43+ * The command-line arguments to some commands may contain the
44+ * encrypted password set by the user. Don't log that password,
45+ * since the log may get posted to bug reports, or stored in
46+ * the target system.
47+ */
48+struct RedactedList
49+{
50+ RedactedList( const QStringList& l )
51+ : list(l)
52+ {
53+ }
54+
55+ const QStringList& list;
56+} ;
57+
58+QDebug&
59+operator<<( QDebug& s, const RedactedList& l )
60+{
61+ // Special case logging: don't log the (encrypted) password.
62+ if ( l.list.contains( "usermod" ) )
63+ {
64+ for ( const auto& item : l.list )
65+ if ( item.startsWith( "$6$" ) )
66+ s << "<password>";
67+ else
68+ s << item;
69+ }
70+ else
71+ s << l.list;
72+
73+ return s;
74+}
75+
4176 namespace CalamaresUtils
4277 {
4378
@@ -158,7 +193,7 @@ System::runCommand(
158193 return -3;
159194 }
160195
161- cDebug() << "Running" << program << arguments;
196+ cDebug() << "Running" << program << RedactedList( arguments );
162197 process.start();
163198 if ( !process.waitForStarted() )
164199 {
@@ -191,7 +226,7 @@ System::runCommand(
191226 cDebug() << "Finished. Exit code:" << r;
192227 if ( ( r != 0 ) || Calamares::Settings::instance()->debugMode() )
193228 {
194- cDebug() << "Target cmd:" << args;
229+ cDebug() << "Target cmd:" << RedactedList( args );
195230 cDebug().noquote().nospace() << "Target output:\n" << output;
196231 }
197232 return ProcessResult(r, output);
Show on old repository browser