11/* upsset - CGI program to manage read/write variables
22
33 Copyright (C) 1999 Russell Kroll <rkroll@exploits.org>
4+ Copyright (C) 2020-2026 Jim Klimov <jimklimov+nut@gmail.com>
45
56 This program is free software; you can redistribute it and/or modify
67 it under the terms of the GNU General Public License as published by
@@ -1116,14 +1117,14 @@ int main(int argc, char **argv)
11161117 int i ;
11171118
11181119#ifdef WIN32
1119- /* Required ritual before calling any socket functions */
1120- static WSADATA WSAdata ;
1121- static int WSA_Started = 0 ;
1122- if (!WSA_Started ) {
1123- WSAStartup (2 , & WSAdata );
1124- atexit ((void (* )(void ))WSACleanup );
1125- WSA_Started = 1 ;
1126- }
1120+ /* Required ritual before calling any socket functions */
1121+ static WSADATA WSAdata ;
1122+ static int WSA_Started = 0 ;
1123+ if (!WSA_Started ) {
1124+ WSAStartup (2 , & WSAdata );
1125+ atexit ((void (* )(void ))WSACleanup );
1126+ WSA_Started = 1 ;
1127+ }
11271128
11281129 /* Avoid binary output conversions, e.g.
11291130 * mangling what looks like CRLF on WIN32 */
@@ -1136,7 +1137,9 @@ int main(int argc, char **argv)
11361137 NUT_UNUSED_VARIABLE (argv );
11371138 username = password = function = monups = NULL ;
11381139
1139- printf ("Content-type: text/html\n\n" );
1140+ printf ("Content-type: text/html\n" );
1141+ printf ("Pragma: no-cache\n" );
1142+ printf ("\n" );
11401143
11411144 /* NOTE: Caller must `export NUT_DEBUG_LEVEL` to see debugs for upsc
11421145 * and NUT methods called from it. This line aims to just initialize
@@ -1148,6 +1151,20 @@ int main(int argc, char **argv)
11481151 nut_debug_level = i ;
11491152 }
11501153
1154+ #ifdef NUT_CGI_DEBUG_UPSSET
1155+ # if (NUT_CGI_DEBUG_UPSSET - 0 < 1 )
1156+ # undef NUT_CGI_DEBUG_UPSSET
1157+ # define NUT_CGI_DEBUG_UPSSET 6
1158+ # endif
1159+ /* Un-comment via make flags when developer-troubleshooting: */
1160+ nut_debug_level = NUT_CGI_DEBUG_UPSSET ;
1161+ #endif
1162+
1163+ if (nut_debug_level > 0 ) {
1164+ cgilogbit_set ();
1165+ printf ("<p>NUT CGI Debugging enabled, level: %d</p>\n\n" , nut_debug_level );
1166+ }
1167+
11511168 /* see if the magic string is present in the config file */
11521169 check_conf ();
11531170
0 commit comments