1 /***************************************************************************
2 * Copyright (C) 2005-2018 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
33 # include <QSslSocket>
34 # include "sslserver.h"
36 # include <QTcpSocket>
37 # include <QTcpServer>
40 #include "authenticator.h"
41 #include "bufferinfo.h"
42 #include "deferredptr.h"
43 #include "identserver.h"
45 #include "oidentdconfiggenerator.h"
46 #include "sessionthread.h"
50 class CoreAuthHandler;
58 class AbstractSqlMigrationReader;
59 class AbstractSqlMigrationWriter;
61 class Core : public QObject
66 static Core *instance();
71 /*** Storage access ***/
72 // These methods are threadsafe.
76 * \param userName The user's login name
77 * \param password The user's uncrypted password
78 * \return The user's ID if valid; 0 otherwise
80 static inline UserId validateUser(const QString &userName, const QString &password) {
81 return instance()->_storage->validateUser(userName, password);
84 //! Authenticate user against auth backend
86 * \param userName The user's login name
87 * \param password The user's uncrypted password
88 * \return The user's ID if valid; 0 otherwise
90 static inline UserId authenticateUser(const QString &userName, const QString &password) {
91 return instance()->_authenticator->validateUser(userName, password);
94 //! Add a new user, exposed so auth providers can call this without being the storage.
96 * \param userName The user's login name
97 * \param password The user's uncrypted password
98 * \param authenticator The name of the auth provider service used to log the user in, defaults to "Database".
99 * \return The user's ID if valid; 0 otherwise
101 static inline UserId addUser(const QString &userName, const QString &password, const QString &authenticator = "Database") {
102 return instance()->_storage->addUser(userName, password, authenticator);
105 //! Does a comparison test against the authenticator in the database and the authenticator currently in use for a UserID.
107 * \param userid The user's ID (note: not login name).
108 * \param authenticator The name of the auth provider service used to log the user in, defaults to "Database".
109 * \return True if the userid was configured with the passed authenticator, false otherwise.
111 static inline bool checkAuthProvider(const UserId userid, const QString &authenticator) {
112 return instance()->_storage->getUserAuthenticator(userid) == authenticator;
115 //! Change a user's password
117 * \param userId The user's ID
118 * \param password The user's unencrypted new password
119 * \return true, if the password change was successful
121 static bool changeUserPassword(UserId userId, const QString &password);
123 //! Check if we can change a user password.
125 * \param userID The user's ID
126 * \return true, if we can change their password, false otherwise
128 static bool canChangeUserPassword(UserId userId);
130 //! Store a user setting persistently
132 * \param userId The users Id
133 * \param settingName The Name of the Setting
134 * \param data The Value
136 static inline void setUserSetting(UserId userId, const QString &settingName, const QVariant &data)
138 instance()->_storage->setUserSetting(userId, settingName, data);
142 //! Retrieve a persistent user setting
144 * \param userId The users Id
145 * \param settingName The Name of the Setting
146 * \param defaultValue Value to return in case it's unset.
147 * \return the Value of the Setting or the default value if it is unset.
149 static inline QVariant getUserSetting(UserId userId, const QString &settingName, const QVariant &defaultValue = QVariant())
151 return instance()->_storage->getUserSetting(userId, settingName, defaultValue);
155 /* Identity handling */
156 static inline IdentityId createIdentity(UserId user, CoreIdentity &identity)
158 return instance()->_storage->createIdentity(user, identity);
162 static bool updateIdentity(UserId user, const CoreIdentity &identity)
164 return instance()->_storage->updateIdentity(user, identity);
168 static void removeIdentity(UserId user, IdentityId identityId)
170 instance()->_storage->removeIdentity(user, identityId);
174 static QList<CoreIdentity> identities(UserId user)
176 return instance()->_storage->identities(user);
180 //! Create a Network in the Storage and store it's Id in the given NetworkInfo
181 /** \note This method is thredsafe.
183 * \param user The core user
184 * \param networkInfo a NetworkInfo definition to store the newly created ID in
185 * \return true if successfull.
187 static bool createNetwork(UserId user, NetworkInfo &info);
189 //! Apply the changes to NetworkInfo info to the storage engine
190 /** \note This method is thredsafe.
192 * \param user The core user
193 * \param networkInfo The Updated NetworkInfo
194 * \return true if successfull.
196 static inline bool updateNetwork(UserId user, const NetworkInfo &info)
198 return instance()->_storage->updateNetwork(user, info);
202 //! Permanently remove a Network and all the data associated with it.
203 /** \note This method is thredsafe.
205 * \param user The core user
206 * \param networkId The network to delete
207 * \return true if successfull.
209 static inline bool removeNetwork(UserId user, const NetworkId &networkId)
211 return instance()->_storage->removeNetwork(user, networkId);
215 //! Returns a list of all NetworkInfos for the given UserId user
216 /** \note This method is thredsafe.
218 * \param user The core user
219 * \return QList<NetworkInfo>.
221 static inline QList<NetworkInfo> networks(UserId user)
223 return instance()->_storage->networks(user);
227 //! Get a list of Networks to restore
228 /** Return a list of networks the user was connected at the time of core shutdown
229 * \note This method is threadsafe.
231 * \param user The User Id in question
233 static inline QList<NetworkId> connectedNetworks(UserId user)
235 return instance()->_storage->connectedNetworks(user);
239 //! Update the connected state of a network
240 /** \note This method is threadsafe
242 * \param user The Id of the networks owner
243 * \param networkId The Id of the network
244 * \param isConnected whether the network is connected or not
246 static inline void setNetworkConnected(UserId user, const NetworkId &networkId, bool isConnected)
248 return instance()->_storage->setNetworkConnected(user, networkId, isConnected);
252 //! Get a hash of channels with their channel keys for a given network
253 /** The keys are channel names and values are passwords (possibly empty)
254 * \note This method is threadsafe
256 * \param user The id of the networks owner
257 * \param networkId The Id of the network
259 static inline QHash<QString, QString> persistentChannels(UserId user, const NetworkId &networkId)
261 return instance()->_storage->persistentChannels(user, networkId);
265 //! Update the connected state of a channel
266 /** \note This method is threadsafe
268 * \param user The Id of the networks owner
269 * \param networkId The Id of the network
270 * \param channel The name of the channel
271 * \param isJoined whether the channel is connected or not
273 static inline void setChannelPersistent(UserId user, const NetworkId &networkId, const QString &channel, bool isJoined)
275 return instance()->_storage->setChannelPersistent(user, networkId, channel, isJoined);
279 //! Get a hash of buffers with their ciphers for a given network
280 /** The keys are channel names and values are ciphers (possibly empty)
281 * \note This method is threadsafe
283 * \param user The id of the networks owner
284 * \param networkId The Id of the network
286 static inline QHash<QString, QByteArray> bufferCiphers(UserId user, const NetworkId &networkId)
288 return instance()->_storage->bufferCiphers(user, networkId);
292 //! Update the cipher of a buffer
293 /** \note This method is threadsafe
295 * \param user The Id of the networks owner
296 * \param networkId The Id of the network
297 * \param bufferName The Cname of the buffer
298 * \param cipher The cipher for the buffer
300 static inline void setBufferCipher(UserId user, const NetworkId &networkId, const QString &bufferName, const QByteArray &cipher)
302 return instance()->_storage->setBufferCipher(user, networkId, bufferName, cipher);
306 //! Update the key of a channel
307 /** \note This method is threadsafe
309 * \param user The Id of the networks owner
310 * \param networkId The Id of the network
311 * \param channel The name of the channel
312 * \param key The key of the channel (possibly empty)
314 static inline void setPersistentChannelKey(UserId user, const NetworkId &networkId, const QString &channel, const QString &key)
316 return instance()->_storage->setPersistentChannelKey(user, networkId, channel, key);
320 //! retrieve last known away message for session restore
321 /** \note This method is threadsafe
323 * \param user The Id of the networks owner
324 * \param networkId The Id of the network
326 static inline QString awayMessage(UserId user, NetworkId networkId)
328 return instance()->_storage->awayMessage(user, networkId);
332 //! Make away message persistent for session restore
333 /** \note This method is threadsafe
335 * \param user The Id of the networks owner
336 * \param networkId The Id of the network
337 * \param awayMsg The current away message of own user
339 static inline void setAwayMessage(UserId user, NetworkId networkId, const QString &awayMsg)
341 return instance()->_storage->setAwayMessage(user, networkId, awayMsg);
345 //! retrieve last known user mode for session restore
346 /** \note This method is threadsafe
348 * \param user The Id of the networks owner
349 * \param networkId The Id of the network
351 static inline QString userModes(UserId user, NetworkId networkId)
353 return instance()->_storage->userModes(user, networkId);
357 //! Make our user modes persistent for session restore
358 /** \note This method is threadsafe
360 * \param user The Id of the networks owner
361 * \param networkId The Id of the network
362 * \param userModes The current user modes of own user
364 static inline void setUserModes(UserId user, NetworkId networkId, const QString &userModes)
366 return instance()->_storage->setUserModes(user, networkId, userModes);
370 //! Get the unique BufferInfo for the given combination of network and buffername for a user.
371 /** \note This method is threadsafe.
373 * \param user The core user who owns this buffername
374 * \param networkId The network id
375 * \param type The type of the buffer (StatusBuffer, Channel, etc.)
376 * \param buffer The buffer name (if empty, the net's status buffer is returned)
377 * \param create Whether or not the buffer should be created if it doesnt exist
378 * \return The BufferInfo corresponding to the given network and buffer name, or 0 if not found
380 static inline BufferInfo bufferInfo(UserId user, const NetworkId &networkId, BufferInfo::Type type, const QString &buffer = "", bool create = true)
382 return instance()->_storage->bufferInfo(user, networkId, type, buffer, create);
386 //! Get the unique BufferInfo for a bufferId
387 /** \note This method is threadsafe
388 * \param user The core user who owns this buffername
389 * \param bufferId The id of the buffer
390 * \return The BufferInfo corresponding to the given buffer id, or an invalid BufferInfo if not found.
392 static inline BufferInfo getBufferInfo(UserId user, const BufferId &bufferId)
394 return instance()->_storage->getBufferInfo(user, bufferId);
398 //! Store a Message in the storage backend and set it's unique Id.
399 /** \note This method is threadsafe.
401 * \param message The message object to be stored
402 * \return true on success
404 static inline bool storeMessage(Message &message)
406 return instance()->_storage->logMessage(message);
410 //! Store a list of Messages in the storage backend and set their unique Id.
411 /** \note This method is threadsafe.
413 * \param messages The list message objects to be stored
414 * \return true on success
416 static inline bool storeMessages(MessageList &messages)
418 return instance()->_storage->logMessages(messages);
422 //! Request a certain number messages stored in a given buffer.
423 /** \param buffer The buffer we request messages from
424 * \param first if != -1 return only messages with a MsgId >= first
425 * \param last if != -1 return only messages with a MsgId < last
426 * \param limit if != -1 limit the returned list to a max of \limit entries
427 * \return The requested list of messages
429 static inline QList<Message> requestMsgs(UserId user, BufferId bufferId, MsgId first = -1, MsgId last = -1, int limit = -1)
431 return instance()->_storage->requestMsgs(user, bufferId, first, last, limit);
435 //! Request a certain number messages stored in a given buffer, matching certain filters
436 /** \param buffer The buffer we request messages from
437 * \param first if != -1 return only messages with a MsgId >= first
438 * \param last if != -1 return only messages with a MsgId < last
439 * \param limit if != -1 limit the returned list to a max of \limit entries
440 * \param type The Message::Types that should be returned
441 * \return The requested list of messages
443 static inline QList<Message> requestMsgsFiltered(UserId user, BufferId bufferId, MsgId first = -1, MsgId last = -1,
444 int limit = -1, Message::Types type = Message::Types{-1},
445 Message::Flags flags = Message::Flags{-1})
447 return instance()->_storage->requestMsgsFiltered(user, bufferId, first, last, limit, type, flags);
451 //! Request a certain number of messages across all buffers
452 /** \param first if != -1 return only messages with a MsgId >= first
453 * \param last if != -1 return only messages with a MsgId < last
454 * \param limit Max amount of messages
455 * \return The requested list of messages
457 static inline QList<Message> requestAllMsgs(UserId user, MsgId first = -1, MsgId last = -1, int limit = -1)
459 return instance()->_storage->requestAllMsgs(user, first, last, limit);
463 //! Request a certain number of messages across all buffers, matching certain filters
464 /** \param first if != -1 return only messages with a MsgId >= first
465 * \param last if != -1 return only messages with a MsgId < last
466 * \param limit Max amount of messages
467 * \param type The Message::Types that should be returned
468 * \return The requested list of messages
470 static inline QList<Message> requestAllMsgsFiltered(UserId user, MsgId first = -1, MsgId last = -1, int limit = -1,
471 Message::Types type = Message::Types{-1},
472 Message::Flags flags = Message::Flags{-1})
474 return instance()->_storage->requestAllMsgsFiltered(user, first, last, limit, type, flags);
478 //! Request a list of all buffers known to a user.
479 /** This method is used to get a list of all buffers we have stored a backlog from.
480 * \note This method is threadsafe.
482 * \param user The user whose buffers we request
483 * \return A list of the BufferInfos for all buffers as requested
485 static inline QList<BufferInfo> requestBuffers(UserId user)
487 return instance()->_storage->requestBuffers(user);
491 //! Request a list of BufferIds for a given NetworkId
492 /** \note This method is threadsafe.
494 * \param user The user whose buffers we request
495 * \param networkId The NetworkId of the network in question
496 * \return List of BufferIds belonging to the Network
498 static inline QList<BufferId> requestBufferIdsForNetwork(UserId user, NetworkId networkId)
500 return instance()->_storage->requestBufferIdsForNetwork(user, networkId);
504 //! Remove permanently a buffer and it's content from the storage backend
505 /** This call cannot be reverted!
506 * \note This method is threadsafe.
508 * \param user The user who is the owner of the buffer
509 * \param bufferId The bufferId
510 * \return true if successfull
512 static inline bool removeBuffer(const UserId &user, const BufferId &bufferId)
514 return instance()->_storage->removeBuffer(user, bufferId);
519 /** \note This method is threadsafe.
520 * \param user The id of the buffer owner
521 * \param bufferId The bufferId
522 * \param newName The new name of the buffer
523 * \return true if successfull
525 static inline bool renameBuffer(const UserId &user, const BufferId &bufferId, const QString &newName)
527 return instance()->_storage->renameBuffer(user, bufferId, newName);
531 //! Merge the content of two Buffers permanently. This cannot be reversed!
532 /** \note This method is threadsafe.
533 * \param user The id of the buffer owner
534 * \param bufferId1 The bufferId of the remaining buffer
535 * \param bufferId2 The buffer that is about to be removed
536 * \return true if successfulln
538 static inline bool mergeBuffersPermanently(const UserId &user, const BufferId &bufferId1, const BufferId &bufferId2)
540 return instance()->_storage->mergeBuffersPermanently(user, bufferId1, bufferId2);
544 //! Update the LastSeenDate for a Buffer
545 /** This Method is used to make the LastSeenDate of a Buffer persistent
546 * \note This method is threadsafe.
548 * \param user The Owner of that Buffer
549 * \param bufferId The buffer id
550 * \param MsgId The Message id of the message that has been just seen
552 static inline void setBufferLastSeenMsg(UserId user, const BufferId &bufferId, const MsgId &msgId)
554 return instance()->_storage->setBufferLastSeenMsg(user, bufferId, msgId);
557 //! Get the auth username associated with a userId
558 /** \param user The user to retrieve the username for
559 * \return The username for the user
561 static inline QString getAuthUserName(UserId user) {
562 return instance()->_storage->getAuthUserName(user);
565 //! Get a usable sysident for the given user in oidentd-strict mode
566 /** \param user The user to retrieve the sysident for
567 * \return The authusername
569 QString strictSysIdent(UserId user) const;
572 //! Get a Hash of all last seen message ids
573 /** This Method is called when the Quassel Core is started to restore the lastSeenMsgIds
574 * \note This method is threadsafe.
576 * \param user The Owner of the buffers
578 static inline QHash<BufferId, MsgId> bufferLastSeenMsgIds(UserId user)
580 return instance()->_storage->bufferLastSeenMsgIds(user);
584 //! Update the MarkerLineMsgId for a Buffer
585 /** This Method is used to make the marker line position of a Buffer persistent
586 * \note This method is threadsafe.
588 * \param user The Owner of that Buffer
589 * \param bufferId The buffer id
590 * \param MsgId The Message id where the marker line should be placed
592 static inline void setBufferMarkerLineMsg(UserId user, const BufferId &bufferId, const MsgId &msgId)
594 return instance()->_storage->setBufferMarkerLineMsg(user, bufferId, msgId);
598 //! Get a Hash of all marker line message ids
599 /** This Method is called when the Quassel Core is started to restore the MarkerLineMsgIds
600 * \note This method is threadsafe.
602 * \param user The Owner of the buffers
604 static inline QHash<BufferId, MsgId> bufferMarkerLineMsgIds(UserId user)
606 return instance()->_storage->bufferMarkerLineMsgIds(user);
609 //! Update the BufferActivity for a Buffer
610 /** This Method is used to make the activity state of a Buffer persistent
611 * \note This method is threadsafe.
613 * \param user The Owner of that Buffer
614 * \param bufferId The buffer id
615 * \param MsgId The Message id where the marker line should be placed
617 static inline void setBufferActivity(UserId user, BufferId bufferId, Message::Types activity) {
618 return instance()->_storage->setBufferActivity(user, bufferId, activity);
622 //! Get a Hash of all buffer activity states
623 /** This Method is called when the Quassel Core is started to restore the BufferActivity
624 * \note This method is threadsafe.
626 * \param user The Owner of the buffers
628 static inline QHash<BufferId, Message::Types> bufferActivities(UserId user) {
629 return instance()->_storage->bufferActivities(user);
632 //! Get the bitset of buffer activity states for a buffer
633 /** This method is used to load the activity state of a buffer when its last seen message changes.
634 * \note This method is threadsafe.
636 * \param bufferId The buffer
637 * \param lastSeenMsgId The last seen message
639 static inline Message::Types bufferActivity(BufferId bufferId, MsgId lastSeenMsgId) {
640 return instance()->_storage->bufferActivity(bufferId, lastSeenMsgId);
643 //! Update the highlight count for a Buffer
644 /** This Method is used to make the highlight count state of a Buffer persistent
645 * \note This method is threadsafe.
647 * \param user The Owner of that Buffer
648 * \param bufferId The buffer id
649 * \param MsgId The Message id where the marker line should be placed
651 static inline void setHighlightCount(UserId user, BufferId bufferId, int highlightCount) {
652 return instance()->_storage->setHighlightCount(user, bufferId, highlightCount);
656 //! Get a Hash of all highlight count states
657 /** This Method is called when the Quassel Core is started to restore the highlight count
658 * \note This method is threadsafe.
660 * \param user The Owner of the buffers
662 static inline QHash<BufferId, int> highlightCounts(UserId user) {
663 return instance()->_storage->highlightCounts(user);
665 //! Get the highlight count states for a buffer
666 /** This method is used to load the highlight count of a buffer when its last seen message changes.
667 * \note This method is threadsafe.
669 * \param bufferId The buffer
670 * \param lastSeenMsgId The last seen message
672 static inline int highlightCount(BufferId bufferId, MsgId lastSeenMsgId) {
673 return instance()->_storage->highlightCount(bufferId, lastSeenMsgId);
676 static inline QDateTime startTime() { return instance()->_startTime; }
677 static inline bool isConfigured() { return instance()->_configured; }
680 * Whether or not strict ident mode is enabled, locking users' idents to Quassel username
682 * @return True if strict mode enabled, otherwise false
684 static inline bool strictIdentEnabled() { return instance()->_strictIdentEnabled; }
686 static bool sslSupported();
688 static QVariantList backendInfo();
689 static QVariantList authenticatorInfo();
691 static QString setup(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData, const QString &authenticator, const QVariantMap &authSetupMap);
693 static inline QTimer *syncTimer() { return &instance()->_storageSyncTimer; }
695 inline OidentdConfigGenerator *oidentdConfigGenerator() const { return _oidentdConfigGenerator; }
696 inline IdentServer *identServer() const { return _identServer; }
698 static const int AddClientEventId;
701 //! Sent when a BufferInfo is updated in storage.
702 void bufferInfoUpdated(UserId user, const BufferInfo &info);
704 //! Relay from CoreSession::sessionState(). Used for internal connection only
705 void sessionState(const Protocol::SessionState &sessionState);
707 //! Emitted when database schema upgrade starts or ends
708 void dbUpgradeInProgress(bool inProgress);
715 * @note This method is threadsafe.
720 * Reload SSL certificates used for connection with clients.
722 * @return True if certificates reloaded successfully, otherwise false.
726 void cacheSysIdent();
728 QString setupCore(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData, const QString &authenticator, const QVariantMap &authSetupMap);
730 void connectInternalPeer(QPointer<InternalPeer> peer);
733 void customEvent(QEvent *event) override;
736 bool startListening();
737 void stopListening(const QString &msg = QString());
738 void incomingConnection();
739 void clientDisconnected();
741 bool initStorage(const QString &backend, const QVariantMap &settings,
742 const QProcessEnvironment &environment, bool loadFromEnvironment,
744 bool initAuthenticator(const QString &backend, const QVariantMap &settings,
745 const QProcessEnvironment &environment, bool loadFromEnvironment,
748 void socketError(QAbstractSocket::SocketError err, const QString &errorString);
749 void setupClientSession(RemotePeer *, UserId);
751 bool changeUserPass(const QString &username);
754 SessionThread *sessionForUser(UserId userId, bool restoreState = false);
755 void addClientHelper(RemotePeer *peer, UserId uid);
756 //void processCoreSetup(QTcpSocket *socket, QVariantMap &msg);
757 QString setupCoreForInternalUsage();
758 void setupInternalClientSession(QPointer<InternalPeer> peer);
762 template<typename Storage>
763 void registerStorageBackend();
765 template<typename Authenticator>
766 void registerAuthenticator();
768 void registerStorageBackends();
769 void registerAuthenticators();
771 DeferredSharedPtr<Storage> storageBackend(const QString& backendId) const;
772 DeferredSharedPtr<Authenticator> authenticator(const QString& authenticatorId) const;
774 bool selectBackend(const QString &backend);
775 bool selectAuthenticator(const QString &backend);
777 bool saveBackendSettings(const QString &backend, const QVariantMap &settings);
778 void saveAuthenticatorSettings(const QString &backend, const QVariantMap &settings);
783 template<typename Backend>
784 QVariantMap promptForSettings(const Backend *backend);
787 static Core *_instance;
788 QSet<CoreAuthHandler *> _connectingClients;
789 QHash<UserId, SessionThread *> _sessions;
790 DeferredSharedPtr<Storage> _storage; ///< Active storage backend
791 DeferredSharedPtr<Authenticator> _authenticator; ///< Active authenticator
792 QMap<UserId, QString> _authUserNames;
794 QTimer _storageSyncTimer;
797 SslServer _server, _v6server;
799 QTcpServer _server, _v6server;
802 OidentdConfigGenerator *_oidentdConfigGenerator {nullptr};
804 std::vector<DeferredSharedPtr<Storage>> _registeredStorageBackends;
805 std::vector<DeferredSharedPtr<Authenticator>> _registeredAuthenticators;
807 QDateTime _startTime;
809 IdentServer *_identServer {nullptr};
811 bool _initialized{false};
812 bool _configured{false};
814 QPointer<InternalPeer> _pendingInternalConnection;
816 /// Whether or not strict ident mode is enabled, locking users' idents to Quassel username
817 bool _strictIdentEnabled;
819 static std::unique_ptr<AbstractSqlMigrationReader> getMigrationReader(Storage *storage);
820 static std::unique_ptr<AbstractSqlMigrationWriter> getMigrationWriter(Storage *storage);
821 static void stdInEcho(bool on);
822 static inline void enableStdInEcho() { stdInEcho(true); }
823 static inline void disableStdInEcho() { stdInEcho(false); }