I have made the following changes intended for :
  CE:MW:Shared / usb-moded

Please review and accept or decline.
BOSS has already run some checks on this request.
See the "Messages from BOSS" section below.

https://build.pub.meego.com//request/show/7698

Thank You,
philippedeswert

[This message was auto-generated]

---

Request # 7698:

Messages from BOSS:

State: review at 2013-01-18T13:24:59 by bossbot

Reviews:
       accepted by bossbot : Prechecks succeeded.
       new for CE-maintainers : Please replace this text with a review and 
approve/reject the review (not the SR). BOSS will take care of the rest

Changes:
  submit: home:philippedeswert:branches:CE:MW:Shared / usb-moded -> 
CE:MW:Shared / usb-moded
  
changes files:
--------------
--- usb-moded.changes
+++ usb-moded.changes
@@ -0,0 +1,4 @@
+* Thu Jan 17 2013 Philippe De Swert <[email protected]> - 0.57
+- Add random mac address generator
+- Apply the dbus patch so we can remove it from the packaging
+

old:
----
  usb-moded-0.38-dbus-policy.patch
  usb-moded-0.56.tar.bz2

new:
----
  usb-moded-0.57.tar.bz2

spec files:
-----------
--- usb-moded.spec
+++ usb-moded.spec
@@ -1,5 +1,5 @@
 Name:     usb-moded
-Version:  0.56
+Version:  0.57
 Release:  0 
 Summary:  USB mode controller
 Group:    System/System Control
@@ -8,7 +8,6 @@
 Source0:  %{name}-%{version}.tar.bz2
 Source1:  %{name}.service
 Source2:  usb_moded.conf
-Patch0:   %{name}-0.38-dbus-policy.patch
 
 BuildRequires: pkgconfig(dbus-1)
 BuildRequires: pkgconfig(dbus-glib-1)
@@ -60,7 +59,6 @@
 
 %prep
 %setup -q
-%patch0 -p0
 
 %build
 %autogen

other changes:
--------------

++++++ usb-moded-0.56.tar.bz2 -> usb-moded-0.57.tar.bz2
--- configure.ac
+++ configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([usb_moded], [0.56])
+AC_INIT([usb_moded], [0.57])
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 
 AM_CONFIG_HEADER([config.h])
--- debian/changelog
+++ debian/changelog
@@ -1,3 +1,9 @@
+usb-moded (0.57) unstable; urgency=low
+
+  * Add random mac generator so host based network tools always get the same 
mac
+
+ -- Philippe De Swert <[email protected]> Thu, 17 Jan 2013 
19:50:37 +0200
+
 usb-moded (0.56) unstable; urgency=low
 
   * Fix possible compiltation issue with N900 support and android which are 
mutually exclusive
--- debian/usb_moded.conf
+++ debian/usb_moded.conf
@@ -8,13 +8,13 @@
                 <allow send_destination="com.meego.usb_moded"
                        send_interface="com.meego.usb_moded"/>
         </policy>
-       <policy user="user">
+       <policy context="default">
                <allow send_destination="com.meego.usb_moded" 
                send_interface="com.meego.usb_moded" send_member="set_mode"/>
                <allow send_destination="com.meego.usb_moded" 
                send_interface="com.meego.usb_moded" 
send_member="mode_request"/>
-        </policy>
-       <policy context="default">
+               <allow send_destination="com.meego.usb_moded" 
+               send_interface="com.meego.usb_moded" send_member="set_config"/>
                 <deny own="com.meego.usb_moded"/>
        </policy>
 </busconfig>
--- docs/usb_moded-doc.txt
+++ docs/usb_moded-doc.txt
@@ -110,6 +110,13 @@
 
 dbus-send --system --type=method_call --print-reply --dest=com.meego.usb_moded 
/com/meego/usb_moded com.meego.usb_moded.net_config string:'ip' 
string:'192.168.2.15'
 
+
+
+Usb_moded will generate a random mac address for the g_ether driver. Thus when 
plugging in the device repeatedly the mac address will not
+change and udev rules / network manager etc will not think it is a new device 
each time.
+This mac is stored using the default modprobe configuration and thus will be 
in /etc/modprobe.d/g_ether.conf
+If this file exits usb_moded will assume there is a default mac set and will 
not do anything.
+
 Functional overview
 --------------------
 
--- src/Makefile.am
+++ src/Makefile.am
@@ -26,7 +26,9 @@
        usb_moded-network.c \
        usb_moded-network.h \
        usb_moded-modesetting.c \
-       usb_moded-modesetting.h 
+       usb_moded-modesetting.h \
+       usb_moded-mac.c \
+       usb_moded-mac.h
 
 if !ANDROID
 usb_moded_SOURCES += \
--- src/usb_moded-mac.c
+++ src/usb_moded-mac.c
@@ -0,0 +1,57 @@
+/**
+  @file usb_moded-mac.c
+
+  Copyright (C) 2013 Jolla. All rights reserved.
+
+  @author: Philippe De Swert <[email protected]>
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the Lesser GNU General Public License 
+  version 2 as published by the Free Software Foundation. 
+
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+ 
+  You should have received a copy of the Lesser GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  02110-1301 USA
+*/
+
+#include <stdio.h>
+#include "usb_moded-mac.h"
+#include "usb_moded-log.h"
+
+static void random_ether_addr(unsigned char *addr)
+{
+  FILE *random; 
+
+  random = fopen("/dev/urandom", "r");
+  fread(addr, 1, 6, random); 
+  fclose(random);
+
+  addr [0] &= 0xfe;       /* clear multicast bit */
+  addr [0] |= 0x02;       /* set local assignment bit (IEEE802) */
+}
+
+void generate_random_mac (void)
+{
+  unsigned char addr[6];
+  int i;
+  FILE *g_ether;
+
+  log_debug("Getting random usb ethernet mac\n");
+  random_ether_addr(addr);
+  
+  g_ether = fopen("/etc/modprobe.d/g_ether.conf", "w");
+  fprintf(g_ether, "options g_ether host_addr=");
+ 
+  for(i=0; i<5; i++)
+  {
+       fprintf(g_ether, "%02x:",addr[i]);
+  }
+  fprintf(g_ether, "%02x\n",addr[i]);
+  fclose(g_ether);
+}
--- src/usb_moded-mac.h
+++ src/usb_moded-mac.h
@@ -0,0 +1,23 @@
+/**
+  @file usb_moded-mac.h
+
+  Copyright (C) 2013 Jolla. All rights reserved.
+
+  @author: Philippe De Swert <[email protected]>
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the Lesser GNU General Public License 
+  version 2 as published by the Free Software Foundation. 
+
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+ 
+  You should have received a copy of the Lesser GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  02110-1301 USA
+*/
+
+void generate_random_mac (void);
--- src/usb_moded.c
+++ src/usb_moded.c
@@ -49,6 +49,7 @@
 #include "usb_moded-config.h"
 #include "usb_moded-config-private.h"
 #include "usb_moded-network.h"
+#include "usb_moded-mac.h"
 
 /* global definitions */
 
@@ -455,6 +456,10 @@
   ctx = kmod_new(NULL, NULL);
   kmod_load_resources(ctx);
 
+  if(access("/etc/modprobe.d/g_ether.conf", F_OK) != 0)
+  {
+    generate_random_mac();     
+  }
   /* TODO: add more start-up clean-up and init here if needed */
 }      
 

++++++ deleted files:
--- usb-moded-0.38-dbus-policy.patch



Reply via email to