summaryrefslogtreecommitdiff
path: root/src/compare.dirs
blob: 563384f1b21aea546b160bfcaf827e7db65bfc96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
--- ./broker.cc	2023-08-22 22:04:58.667689000 +0200
+++ ../../bincimap-2.0.5/src//broker.cc	2023-08-14 12:04:05.654922000 +0200
@@ -105,7 +105,8 @@
 //----------------------------------------------------------------------
 Operator *Broker::get(const string &name) const
 {
-  if (operators.find(name) == operators.end()) return 0;
+  if (operators.find(name) == operators.end())
+    return 0;
 
   return operators.find(name)->second;
 }
--- ./imapserver.cc	2023-08-22 11:30:32.929436000 +0200
+++ ../../bincimap-2.0.5/src//imapserver.cc	2023-08-19 15:30:18.579113000 +0200
@@ -74,7 +74,6 @@
     showGreeting();
   } else {
     bincInfo << "<" << session.getEnv("USER") << "> logged in" << "\n";
-    bincInfo << "<" << getenv("USER") << "> logged in" << "\n";
   }
   bincInfo.flush();
 
--- ./iodevice.cc	2023-08-22 13:38:19.325053000 +0200
+++ ../../bincimap-2.0.5/src//iodevice.cc	2023-08-14 12:59:30.985424000 +0200
@@ -40,11 +40,13 @@
 
   static std::ostream &(*endl_funcptr)(ostream &) = endl;
 
-  if (source != endl_funcptr) return *this;
+  if (source != endl_funcptr)
+    return *this;
 
   outputBuffer << "\r\n";
 
-  if (dumpfd) ::write(dumpfd, "\r\n", 2);
+  if (dumpfd)
+    ::write(dumpfd, "\r\n", 2);
 
   if (flags & FlushesOnEndl)
     flush();
@@ -64,7 +66,8 @@
 //------------------------------------------------------------------------
 void IODevice::clear()
 {
-  if (!(flags & IsEnabled)) return;
+  if (!(flags & IsEnabled))
+    return;
 
   inputBuffer.clear();
   outputBuffer.clear();
@@ -73,20 +76,26 @@
 //------------------------------------------------------------------------
 bool IODevice::flush()
 {
-  if (!(flags & IsEnabled)) return true;
+  if (!(flags & IsEnabled))
+    return true;
 
   WriteResult writeResult = WriteWait;
   do {
     unsigned int s = outputBuffer.getSize();
-    if (s == 0) break;
-    if (!waitForWrite()) return false;
+    if (s == 0)
+      break;
+
+    if (!waitForWrite())
+      return false;
+
     writeResult = write();
-    if (writeResult == WriteError) return false;
+    if (writeResult == WriteError)
+      return false;
+
     writeCount += s - outputBuffer.getSize();
   } while (outputBuffer.getSize() > 0 && writeResult == WriteWait);
 
   outputBuffer.clear();
-
   return true;
 }
 
@@ -159,11 +168,13 @@
 bool IODevice::readStr(string *dest, unsigned int max)
 {
   // If max is 0, fill the input buffer once only if it's empty.
-  if (!max && inputBuffer.getSize() == 0 && !fillInputBuffer()) return false;
+  if (!max && inputBuffer.getSize() == 0 && !fillInputBuffer())
+    return false;
 
   // If max is != 0, wait until we have max.
   while (max && inputBuffer.getSize() < max) {
-      if (!fillInputBuffer()) return false;
+      if (!fillInputBuffer())
+    return false;
   }
 
   unsigned int bytesToRead = max ? max : inputBuffer.getSize();
@@ -174,21 +185,22 @@
   
   inputBuffer.popString(bytesToRead);
   readCount += bytesToRead;
-
   return true;
 }
 
 //------------------------------------------------------------------------
 bool IODevice::readChar(char *dest)
 {
-  if (inputBuffer.getSize() == 0 && !fillInputBuffer()) return false;
+  if (inputBuffer.getSize() == 0 && !fillInputBuffer())
+    return false;
 
   char c = inputBuffer.popChar();
-  if (dest) *dest = c;
-  if (dumpfd) ::write(dumpfd, &c, 1);
+  if (dest)
+    *dest = c;
+  if (dumpfd)
+    ::write(dumpfd, &c, 1);
 
   ++readCount;
-
   return true;
 }
 
@@ -209,8 +221,10 @@
 {
   char dest = '\0';
   do {
-    if (!readChar(&dest)) return false;
-    if (dumpfd) ::write(dumpfd, &dest, 1);
+    if (!readChar(&dest))
+      return false;
+    if (dumpfd)
+      ::write(dumpfd, &dest, 1);
   } while (c != dest);
 
   return true;
@@ -278,6 +292,7 @@
      << Session::getInstance().getIP() << "-XXXXXX";
   char *safename = strdup(ss.str().c_str());
   dumpfd = mkstemp(safename);
-  if (dumpfd == -1) dumpfd = 0;
+  if (dumpfd == -1)
+    dumpfd = 0;
   delete safename;
 }
--- ./operator-authenticate.cc	2023-08-24 10:14:07.627463000 +0200
+++ ../../bincimap-2.0.5/src//operator-authenticate.cc	2023-08-19 15:24:29.665376000 +0200
@@ -166,11 +166,9 @@
 
   putenv(strdup(("BINCIMAP_LOGIN=AUTHENTICATE+" + command.getTag()).c_str()));
 
-  // FEH: put the username in the environment for logging purpose
+  // put the username in the environment for logging purpose
 
-  // FIXME:  
-	session.setEnv("USER", username.c_str());
-//  putenv(strdup(("USER=" + username).c_str()));
+  session.setEnv("USER", username.c_str());
 
   // the authenticate function calls a stub which does the actual
   // authentication. the function returns 0 (success), 1 (internal
--- ./operator-capability.cc	2023-08-23 12:02:49.204839000 +0200
+++ ../../bincimap-2.0.5/src//operator-capability.cc	2023-08-21 15:12:32.915708000 +0200
@@ -12,7 +12,6 @@
 #include "operators.h"
 #include "recursivedescent.h"
 #include "session.h"
-#include "globals.h"
 
 using namespace ::std;
 using namespace Binc;
@@ -37,8 +36,8 @@
 int CapabilityOperator::getState() const
 {
   return Session::NONAUTHENTICATED 
-       | Session::AUTHENTICATED
-       | Session::SELECTED;
+         | Session::AUTHENTICATED
+         | Session::SELECTED;
 }
 
 //----------------------------------------------------------------------
@@ -53,11 +52,10 @@
 {
   Session &session = Session::getInstance();
 
-  bincClient << "* CAPABILITY " << IMAP_VERSION ;
+  bincClient << "* CAPABILITY IMAP4rev1";
 
   if (session.getState() == Session::NONAUTHENTICATED) {
-	  if (getenv("UCSPITLS"))
-      if (!session.command.ssl) bincClient << " STARTTLS";
+    if (!session.command.ssl) bincClient << " STARTTLS";
 
     if (session.command.ssl || session.hasEnv("ALLOW_NONSSL_PLAINTEXT_LOGINS"))
       bincClient << " AUTH=LOGIN AUTH=PLAIN";
--- ./operator-fetch.cc	2023-08-22 11:28:00.260614000 +0200
+++ ../../bincimap-2.0.5/src//operator-fetch.cc	2023-08-21 11:54:04.569792000 +0200
@@ -372,9 +372,9 @@
 
   pendingUpdates(mailbox,
                  PendingUpdates::FLAGS
-               | PendingUpdates::EXISTS
-               | PendingUpdates::EXPUNGE
-               | PendingUpdates::RECENT, true);
+                 | PendingUpdates::EXISTS
+                 | PendingUpdates::EXPUNGE
+                 | PendingUpdates::RECENT, true);
 
   return OK;
 }
--- ./operator-id.cc	2023-08-23 22:43:11.362445000 +0200
+++ ../../bincimap-2.0.5/src//operator-id.cc	2023-08-21 15:05:56.720615000 +0200
@@ -1,8 +1,8 @@
 /**  --------------------------------------------------------------------
  *  @file  operator-id.cc
- *  @brief Operator for the ID extension. Described in RFC2971 Oct 2000.
+ *  @brief Operator for the ID command.
  *  @author Erwin Hoffmann
- *  @date 22.09.2023
+ *  @date 2023
  *  ------------------------------------------------------------------ **/
 #include <string>
 #include <iostream>
@@ -46,10 +46,13 @@
 Operator::ProcessResult IdOperator::process(Depot &depot,
                                             Request &command)
 {
-  bincClient << "* ID (\"name\" \"Binc IMAP\""
+  Session &session = Session::getInstance();
+
+  bincClient << " * ID (\"name\" \"Binc IMAP\"" 
              << " \"version\" \"" << BINC_VERSION "\")" << endl;
+  bincClient.flush();
 
-	return NOTHING;
+	return OK;
 }
 
 //----------------------------------------------------------------------
@@ -57,15 +60,13 @@
 {
   Session &session = Session::getInstance();
 
-  if (c_in.getUidMode()) return REJECT;
+  if (c_in.getUidMode()) return ACCEPT;
 
-/* FIXME: We are not interested in the parsing result
   Operator::ParseResult res;
   if ((res = expectSPACE()) != ACCEPT) {
     session.setLastError("Expected SPACE");
     return res;
   }
-*/
 
   c_in.setName("ID");
 
--- ./operator-login.cc	2023-08-23 22:42:22.681346000 +0200
+++ ../../bincimap-2.0.5/src//operator-login.cc	2023-08-16 19:37:07.694225000 +0200
@@ -48,7 +48,7 @@
 
 //------------------------------------------------------------------------
 Operator::ProcessResult LoginOperator::process(Depot &depot,
-                                               Request &command)
+					       Request &command)
 {
   Session &session = Session::getInstance();
 
@@ -79,7 +79,7 @@
     break;
   case -1:
     bincClient << "* BYE The server died unexpectedly. Please contact "
-                  "your system administrator for more information." << endl;
+      "your system administrator for more information." << endl;
     break;
   }
 
--- ./operator-logout.cc	2023-08-22 13:41:49.546630000 +0200
+++ ../../bincimap-2.0.5/src//operator-logout.cc	2023-08-14 23:04:43.460303000 +0200
@@ -41,8 +41,8 @@
 int LogoutOperator::getState() const
 {
   return Session::NONAUTHENTICATED
-       | Session::AUTHENTICATED
-       | Session::SELECTED;
+                | Session::AUTHENTICATED
+                | Session::SELECTED;
 }
 
 //------------------------------------------------------------------------
--- ./operator-noop.cc	2023-08-22 12:11:45.876657000 +0200
+++ ../../bincimap-2.0.5/src//operator-noop.cc	2023-08-15 15:05:11.493837000 +0200
@@ -51,7 +51,8 @@
 {
   Session &session = Session::getInstance();
 
-  if (c_in.getUidMode()) return REJECT;
+  if (c_in.getUidMode())
+    return REJECT;
 
   Operator::ParseResult res;
   if ((res = expectCRLF()) != ACCEPT) {
--- ./operator-starttls.cc	2023-08-24 10:24:53.204617000 +0200
+++ ../../bincimap-2.0.5/src//operator-starttls.cc	2023-08-19 16:15:15.622679000 +0200
@@ -1,13 +1,11 @@
 /**  --------------------------------------------------------------------
  *  @file  operator-starttls.cc
- *  @brief  Implementation of the STARTTLS command - based on sslserver 
- *  @author Andreas Aardal Hanssen, Erwin Hoffmann
- *  @date 2002-2005, 2023
+ *  @brief  Implementation of the STARTTLS command.
+ *  @author Andreas Aardal Hanssen
+ *  @date 2002-2005
  *  -----------------------------------------------------------------  **/
 #include <string>
 #include <iostream>
-#include <unistd.h>
-#include <fcntl.h>
 
 #include "recursivedescent.h"
 #include "iodevice.h"
@@ -43,37 +41,6 @@
        | Session::SELECTED;
 }
 
-//----------------------------------------------------------------------
-int StarttlsOperator::goStartTLS () const
-{
-  Session &session = Session::getInstance();
-
-  if (getenv("UCSPITLS")) {
-    string fdstr;
-    int fd;
-
-    fdstr = session.getEnv("SSLCTLFD");
-    fd = std::stoi(fdstr);
-    if (write(fd,"Y",1) < 1) return NOTHING;
-
-    fdstr = session.getEnv("SSLREADFD");
-    fd = std::stoi(fdstr);
-    if (fcntl(fd,F_GETFL,0) == -1) return NOTHING;
-    close (0); 
-    if (fcntl(fd,F_DUPFD,0) == -1) return NOTHING;
-    close (fd);
-
-    fdstr = session.getEnv("SSLWRITEFD");
-    fd = std::stoi(fdstr);
-    if (fcntl(fd,F_GETFL,0) == -1) return NOTHING;
-    close (1); 
-    if (fcntl(fd,F_DUPFD,1) == -1) return NOTHING;
-    close (fd);
-  }
-
-  return ACCEPT;
-}
-
 //------------------------------------------------------------------------
 Operator::ProcessResult StarttlsOperator::process(Depot &depot,
                                                   Request &command)
@@ -84,13 +51,11 @@
     return BAD;
   }
 
-  bincClient << "OK STARTTLS completed, begin TLS session now" << endl;
+  bincClient << command.getTag() 
+             << " OK STARTTLS completed, begin TLS negotiation now" << endl;
   bincClient.flush();
 
-  if (goStartTLS() == ACCEPT) 
-    session.command.ssl = true;
-  else 
-    return NO;
+  session.command.ssl = true;
 
   return NOTHING;
 }
@@ -100,7 +65,8 @@
 {
   Session &session = Session::getInstance();
 
-  if (c_in.getUidMode()) return REJECT;
+  if (c_in.getUidMode())
+    return REJECT;
 
   Operator::ParseResult res;
   if ((res = expectCRLF()) != ACCEPT) {
--- ./session-initialize-bincimap-up.cc	2023-08-24 10:30:35.277625000 +0200
+++ ../../bincimap-2.0.5/src//session-initialize-bincimap-up.cc	2023-08-21 15:50:02.457680000 +0200
@@ -1,8 +1,8 @@
 /**  --------------------------------------------------------------------
  *  @file  session-initialize-bincimap-up.cc
- *  @brief bincimap-up requires sslserver 
- *  @author Andreas Aardal Hanssen, Erwin Hoffmann
- *  @date 2002-2005, 2023 
+ *  @brief  <--->
+ *  @author Andreas Aardal Hanssen
+ *  @date 2002-2005 
  *  -----------------------------------------------------------------  **/
 #include <syslog.h>
 #include <ctype.h>
@@ -27,6 +27,15 @@
 
 extern char **environ;
 
+namespace {
+  //------------------------------------------------------------------------
+  void usage(char *name)
+  {
+    printf("Please refer to the man pages for bincimap-up and bincimap\n");
+    printf("for more information about how to invoke Binc IMAP.\n");
+  }
+}
+
 //----------------------------------------------------------------------
 bool Session::initialize(int argc, char *argv[])
 {
@@ -51,26 +60,38 @@
     return false;
   }
 
-  // Show version if asked for it
+  // imaps (port 993) -- requires sslserver with option -e
+
+  int stls = 0;
+  string tlssession = session.getEnv("SSL_SESSION_ID");
+  trim(tlssession); 
+  if (tlssession.size() > 2) {
+    session.command.ssl = true;
+    stls = -1 ;
+  }
+
+  // Show help if asked for it
   if (session.command.version) {
-    printf("Binc IMAP v" BINC_VERSION"\n");
+    printf("Binc IMAP v" BINC_VERSION IMAP_VERSION "\n");
     return false;
   }
 
   // Let the command line args override the global settings.
   session.assignCommandLineArgs();
 
-  // for log input
+
+  // log settings
   string ip = getenv("TCP6REMOTEIP") ? getenv("TCP6REMOTEIP") :
               getenv("TCPREMOTEIP") ? getenv("TCPREMOTEIP") : "?";
   session.setIP(ip);
 
+
   string logtype = session.getEnv("LOG_TYPE");
   lowercase(logtype);
   trim(logtype);
   if (logtype == "multilog" || logtype == "stderr") {
-    MultilogDevice *device = new MultilogDevice(IODevice::IsEnabled
-                                              | IODevice::FlushesOnEndl);
+      MultilogDevice *device = new MultilogDevice(IODevice::IsEnabled
+              | IODevice::FlushesOnEndl);
     ioFactory.addDevice(device);
   } else if (logtype == "" || logtype == "syslog") {
     const string f = session.getEnv("SYSLOG_FACILITY");
@@ -89,13 +110,13 @@
       else if (f == "LOG_LOCAL6") facility = LOG_LOCAL6;
       else if (f == "LOG_LOCAL7") facility = LOG_LOCAL7;
       else facility = LOG_DAEMON;
-    }
+    }   
 
     SyslogDevice *device = new SyslogDevice(IODevice::IsEnabled
-                                          | IODevice::FlushesOnEndl,
-                                            "bincimap-up",
-                                            LOG_NDELAY | LOG_PID,
-                                            facility);
+              | IODevice::FlushesOnEndl,
+              "bincimap-up",
+              LOG_NDELAY | LOG_PID,
+              facility);
     ioFactory.addDevice(device);
   }
 
@@ -105,25 +126,34 @@
 
 
   MultilogDevice *device = new MultilogDevice(IODevice::IsEnabled
-                                            | IODevice::FlushesOnEndl);
-  ioFactory.addDevice(device);
+                                              | IODevice::FlushesOnEndl);
+    ioFactory.addDevice(device);
 
   // Now that we know the log type, we can flush.
   IOFactory::getLogger().setFlags(IODevice::FlushesOnEndl);
   IOFactory::getLogger().setOutputLevelLimit(IODevice::InfoLevel);
 
-  // imaps (port 993) -- requires sslserver with option -e
+  string ucspitls = session.getEnv("UCSPITLS");
+  if (ucspitls == "+") stls = 1;
+  if (ucspitls == "-") stls = 0;
+  if (ucspitls == "!") stls = 2;
 
-  int stls = 0;
-  if (getenv("SSL_SESSION_ID")) {
-    session.command.ssl = true;
-    stls = -1;
-    // else we will do starttls - requires new FDs
-  } else if (getenv("UCSPITLS")) {
-      string ucspitls = session.getEnv("UCSPITLS");
-      if (ucspitls == "+") stls = 1;
-      if (ucspitls == "-") stls = 0;
-      if (ucspitls == "!") stls = 2;
+  if (stls > 0) {
+    string fdstr;
+    int fd;
+     fdstr = session.getEnv("SSLCTLFD");
+    fd = std::stoi(fdstr);
+    if (write(fd,"Y",1) < 1) return 0;
+
+    fdstr = session.getEnv("SSLREADFD");
+    fd = std::stoi(fdstr);
+    if (dup2(0,fd) == -1) return 0;
+    close(fd);
+
+    fdstr = session.getEnv("SSLWRITEFD");
+    fd = std::stoi(fdstr);
+    if (dup2(1,fd) == -1) return 0;
+    close(fd);
   }
 
   BrokerFactory &brokerfactory = BrokerFactory::getInstance();
@@ -133,8 +163,7 @@
   brokerfactory.assign("LOGIN", new LoginOperator());
   brokerfactory.assign("LOGOUT", new LogoutOperator());
   brokerfactory.assign("NOOP", new NoopOperator());
-  brokerfactory.assign("ID", new IdOperator());
-  if (stls > 0) brokerfactory.assign("STARTTLS", new StarttlsOperator());
+  if (stls) brokerfactory.assign("STARTTLS", new StarttlsOperator());
 
   bincClient.setTimeout(60);
 
--- ./session-initialize-bincimapd.cc	2023-08-24 10:37:13.007980000 +0200
+++ ../../bincimap-2.0.5/src//session-initialize-bincimapd.cc	2023-08-21 12:20:24.757336000 +0200
@@ -1,9 +1,12 @@
-/** --------------------------------------------------------------------
- *  @file session-initialize-bincimapd.cc
- *  @brief  <--->
- *  @author Andreas Aardal Hanssen, Erwin Hoffmann
- *  @date 2002-2005, 2023
+/*  --------------------------------------------------------------------
+ *  Filename:
+ *    session-initialize-bincimap-up.cc
+ *  
+ *  Description:
+ *    <--->
  *  --------------------------------------------------------------------
+ *  Copyright 2002-2005 Andreas Aardal Hanssen
+ *  --------------------------------------------------------------------
  */
 #include <unistd.h>
 #include <syslog.h>
@@ -21,7 +24,6 @@
 #include "syslogdevice.h"
 #include "tools.h"
 #include "convert.h"
-
 #include <string>
 #include <map>
 #include <signal.h>
@@ -31,14 +33,24 @@
 
 extern char **environ;
 
+namespace {
+  //------------------------------------------------------------------------
+  void usage(char *name)
+  {
+    bincInfo << "Please refer to the man pages for bincimap-up and bincimapd"
+	   << endl;
+    bincInfo << "for more information about how to invoke Binc IMAP." << endl;
+    bincInfo.flush();
+  }
+}
+
 //----------------------------------------------------------------------
 bool Session::initialize(int argc, char *argv[])
 {
   IOFactory &ioFactory = IOFactory::getInstance();
-
   IODevice *stdioDevice = new StdIODevice(IODevice::IsEnabled
-                                        | IODevice::HasInputLimit
-                                        | IODevice::HasTimeout);
+                                          | IODevice::HasInputLimit
+                                          | IODevice::HasTimeout);
   stdioDevice->setFlags(IODevice::HasOutputLimit);
   stdioDevice->setMaxOutputBufferSize(TRANSFER_BUFFER_SIZE);
   ioFactory.addDevice(stdioDevice);
@@ -55,9 +67,9 @@
     return false;
   }
 
-  // Show version if asked for it
+  // Show help if asked for it
   if (session.command.version) {
-    printf("Binc IMAP v" BINC_VERSION"\n");
+    printf("Binc IMAP v" BINC_VERSION IMAP_VERSION"\n");
     return false;
   }
 
@@ -96,15 +108,27 @@
     session.setEnv("SYSLOG_FACILITY", toString(facility));
 
     ioFactory.addDevice(new SyslogDevice(IODevice::IsEnabled,
-                                        "bincimapd",
-                                        LOG_NDELAY | LOG_PID,
-                                        facility));
+           "bincimapd",
+           LOG_NDELAY | LOG_PID,
+           facility));
   }
 
   // Now that we know the log type, we can flush.
   IOFactory::getLogger().flush();
   IOFactory::getLogger().setFlags(IODevice::FlushesOnEndl);
   IOFactory::getLogger().setOutputLevelLimit(IODevice::InfoLevel);
+
+  // Show help if asked for it
+  if (session.command.help) {
+    usage(argv[0]);
+    return false;
+  }
+
+  // Show help if asked for it
+  if (session.command.version) {
+    bincInfo << "Binc IMAP v" << BINC_VERSION IMAP_VERSION << endl;
+    return false;
+  }
 
   char *logindetails = getenv("BINCIMAP_LOGIN");
   if (logindetails == 0) {
--- ./session.cc	2023-08-22 11:08:44.043704000 +0200
+++ ../../bincimap-2.0.5/src//session.cc	2023-08-20 13:56:00.410613000 +0200
@@ -137,7 +137,7 @@
 {
   args.addOptional("h|?|help", "Display this help screen", true);
   args.addOptional("version", "Display the version of Binc IMAP", true);
-  args.addOptional("a|allow-plain", "Allow authentication when not TLS protected", true);
+  args.addOptional("a|allow-plain", "Allow authentication when not in SSL", true);
   args.addOptional("v|show-version", "Enable verbose IMAP greeting", false);
   args.addOptional("l|log-type", "Sets the method used for logging", false);
   args.addOptional("d|depot", "Sets the depot type", false);
--- ./syslogdevice.cc	2023-08-22 13:36:36.473713000 +0200
+++ ../../bincimap-2.0.5/src//syslogdevice.cc	2023-08-19 21:24:47.622270000 +0200
@@ -62,7 +62,8 @@
       out += *i;
   }
   
-  if (out != "") syslog(priority, out.c_str(), out.size());
+  if (out != "")
+    syslog(priority, out.c_str(), out.size());
 
   outputBuffer.clear();
   return WriteDone;