Send Motion-user mailing list submissions to
        motion-user@lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.sourceforge.net/lists/listinfo/motion-user
or, via email, send a message with subject or body 'help' to
        motion-user-requ...@lists.sourceforge.net

You can reach the person managing the list at
        motion-user-ow...@lists.sourceforge.net

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Motion-user digest..."


Today's Topics:

   1. suggested patch when using basic_auth to add user:pass@ to
      the links/refs. (Roger Heflin)


----------------------------------------------------------------------

Message: 1
Date: Mon, 5 Sep 2022 19:18:12 -0500
From: Roger Heflin <roger.hef...@gmail.com>
To: Motion discussion list <motion-user@lists.sourceforge.net>
Subject: [Motion-user] suggested patch when using basic_auth to add
        user:pass@ to the links/refs.
Message-ID:
        <CAAMCDeeOqk-wjLmhC=7YkXNB5=TZpbBRU=do+0Oc=yqy-gl...@mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"

This is a patch that when webcontrol_auth_method is  set to
1/basic_autth that on the preview and click on preview it passes the
correct auth through.   I have compiled it and validated that it
appears to work properly.    suggestions on any improvements?

And yes, I know basic auth can be snooped easily to get the user/pass.

diff --git a/src/webu_html.c b/src/webu_html.c
index 2c444c6..4d17e38 100644
--- a/src/webu_html.c
+++ b/src/webu_html.c
@@ -653,6 +653,7 @@ static void webu_html_preview(struct webui_ctx *webui)
     char response[WEBUI_LEN_RESP];
     int indx, indx_st, preview_scale;
     struct strminfo_ctx strm_info;
+    char host_auth_string[256];

     strm_info.cntlst = webui->cntlst;

@@ -683,12 +684,20 @@ static void webu_html_preview(struct webui_ctx *webui)

         strm_info.motion_images = FALSE;
         webu_html_strminfo(&strm_
info,indx);
+
+        if ( webui->cnt->conf.stream_auth_method == 1 ) {
+          
snprintf(host_auth_string,sizeof(host_auth_string),"%s:%s@%s",webui->auth_user,webui->auth_pass,webui->hostname);
+          }
+        else {
+          
snprintf(host_auth_string,sizeof(host_auth_string),"%s",webui->hostname);
+          }
+
         snprintf(response, sizeof (response),
             "      <a href=%s://%s:%d%s%s> "
             " <img src=%s://%s:%d%s%s border=0 width=%d%%></a>\n"
-            ,strm_info.proto, webui->hostname, strm_info.port
+            ,strm_info.proto, host_auth_string, strm_info.port
             ,strm_info.lnk_camid, strm_info.lnk_ref
-            ,strm_info.proto, webui->hostname, strm_info.port
+            ,strm_info.proto, host_auth_string, strm_info.port
             ,strm_info.lnk_camid, strm_info.lnk_src
             ,preview_scale);
         webu_write(webui, response);
@@ -699,9 +708,9 @@ static void webu_html_preview(struct webui_ctx *webui)
             snprintf(response, sizeof (response),
                 "      <a href=%s://%s:%d%s%s> "
                 " <img src=%s://%s:%d%s%s class=border width=%d%%></a>\n"
-                ,strm_info.proto, webui->hostname, strm_info.port
+                ,strm_info.proto, host_auth_string, strm_info.port
                 ,strm_info.lnk_camid, strm_info.lnk_ref
-                ,strm_info.proto, webui->hostname, strm_info.port
+                ,strm_info.proto, host_auth_string, strm_info.port
                 ,strm_info.lnk_camid, strm_info.lnk_src
                 ,preview_scale);
             webu_write(webui, response);



------------------------------



------------------------------

Subject: Digest Footer

_______________________________________________
Motion-user mailing list
Motion-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/motion-user


------------------------------

End of Motion-user Digest, Vol 195, Issue 2
*******************************************

Reply via email to