WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Is findshares open source?  (Read 29123 times)

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: Is findshares open source?
« Reply #15 on: February 28, 2014, 08:00:01 PM »
Hi Scooby
  9 bit  -256=100
16 bit  -256=FF00
32 bit  -256=FFFFFF00
48 bit  -256=FFFFFFFFFF00
64 bit  -256=FFFFFFFFFFFFFF00
As you go to longer data formats the sign bit (most significant bit) is copied to the higher order bits.

Offline Scooby

  • Newbie
  • *
  • Posts: 27
Re: Is findshares open source?
« Reply #16 on: March 01, 2014, 11:07:59 AM »
Thank you for lesson.

I will go with this and run for a while to see if something
is not right.

I may have to consult you again

Thanks for support

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: Is findshares open source?
« Reply #17 on: March 01, 2014, 11:40:06 AM »
Hi Scooby
No problem.
Code: [Select]
root@alphaos ~]# findshares
findshares version 1.05 Aug 3, 2011
Copyright Richard A. Rost April 23, 2011

Local Host Name  = alphaos
Local IP Address = 192.168.1.59 on wlan0

Error line 445
Samba/Windows Shares
--------------------------------------------------------------------------------
MSHOME
    RT-N66U          192.168.1.2       RT-N66U
   IPC$                           IPC Service (RT-N66U)


    DADS-MAC-MINI    192.168.1.10     

MSHOME
        xxxxx       192.168.1.55      Samba (xxxxx)
   media                          media
   removable_SDCARD               removable_media_SDCARD
   IPC$                           IPC Service (Samba (xxxxx))
I suspect that the  "LINE 445"  error message may be from  DADS-MAC-MINI    192.168.1.10.  I don't see any shares listed
for it.

Offline Scooby

  • Newbie
  • *
  • Posts: 27
Re: Is findshares open source?
« Reply #18 on: March 07, 2014, 03:20:32 PM »
I got some problems. And I tried with our different version of findshares.

I setup a linux lite on VirtualBox with a host-only network (ie not on eth0 but vboxnet0) and created a share.
The share server has gets ip 192.168.56.102. I can find it with nmap and smbclient
but findshares don't seem to find it. Tried on 64 bit version

Any clue why findshares doesn't find it?

Code: [Select]
> ./findshares

findshares version 1.05 Aug 3, 2011
Copyright Richard A. Rost April 23, 2011

Local Host Name  = alphaos
Local IP Address = 172.19.8.182 on wlan0
Local IP Address = 192.168.56.1 on vboxnet0
Local IP Address = 192.168.56.101 on vboxnet0

Code: [Select]
> map 192.168.56.0/24

Nmap scan report for 192.168.56.1
Host is up (0.0000060s latency).
All 1000 scanned ports on 192.168.56.1 are closed

Nmap scan report for 192.168.56.100
Host is up (0.000044s latency).
All 1000 scanned ports on 192.168.56.100 are filtered
MAC Address: 08:00:27:81:FC:F4 (Cadmus Computer Systems)

Nmap scan report for 192.168.56.102
Host is up (0.00032s latency).
Not shown: 998 closed ports
PORT    STATE SERVICE
139/tcp open  netbios-ssn
445/tcp open  microsoft-ds
MAC Address: 08:00:27:F5:0C:62 (Cadmus Computer Systems)

Nmap scan report for 192.168.56.101
Host is up (0.0000060s latency).
All 1000 scanned ports on 192.168.56.101 are closed

Code: [Select]
> smbclient -L 192.168.56.102

Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.3]

Sharename       Type      Comment
---------       ----      -------
everyoneshare   Disk     
IPC$            IPC       IPC Service (Samba Server 3.6.3)
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.3]

Server               Comment
---------            -------
LINUXLITE            Samba Server 3.6.3

Workgroup            Master
---------            -------
WORKGROUP            LINUXLITE
« Last Edit: March 07, 2014, 04:56:21 PM by Scooby »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: Is findshares open source?
« Reply #19 on: March 08, 2014, 09:52:37 PM »
Hi Scooby
The  getifaddrs  call returns a linked list of all available interfaces. When I wrote the program, I included provisions to save
and list up to 10 interfaces. The program was hard coded to scan only the first interface in the list. Multiple interfaces has
not come up until now. I've attached an update version that should scan all interfaces found (up to 10). I don't have any
machines with multiple NICs so you'll have to test.
Quote
> ./findshares

findshares version 1.05 Aug 3, 2011
Copyright Richard A. Rost April 23, 2011

Local Host Name  = alphaos
Local IP Address = 172.19.8.182 on wlan0
Local IP Address = 192.168.56.1 on vboxnet0
Local IP Address = 192.168.56.101 on vboxnet0
The 192.168.56 addresses will both be scanned.

    [EDIT]: Newer version attached 3/11/14
« Last Edit: March 11, 2014, 12:48:36 PM by Rich »

Offline Scooby

  • Newbie
  • *
  • Posts: 27
Re: Is findshares open source?
« Reply #20 on: March 10, 2014, 01:40:22 PM »
I will try it out now and report back.

Thanks for fast update  :)

*edit*

So compiled new code and it found shares however there is a
Segmentation fault at the end of output?

Any way I can find out were it segfaults?

Code: [Select]
findshares version 1.06 Mar 8, 2014
Copyright Richard A. Rost April 23, 2011

Local Host Name  = alphaos
Local IP Address = 172.19.8.156 on wlan0
Local IP Address = 192.168.56.1 on vboxnet0
Local IP Address = 192.168.56.101 on vboxnet0

Samba/Windows Shares
--------------------------------------------------------------------------------
WORKGROUP
    LINUXLITE        192.168.56.102    Samba Server 3.6.3
everyoneshare                 
IPC$                           IPC Service (Samba Server 3.6.3)

Segmentation fault
« Last Edit: March 10, 2014, 02:06:53 PM by Scooby »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: Is findshares open source?
« Reply #21 on: March 10, 2014, 02:27:39 PM »
Hi Scooby
Go to the end of the file and change:
Code: [Select]
for(subnet=1; subnet < 255; subnet++)
{
if(SMBshares[subnet] != NULL)
free(SMBshares[subnet]);
}
free(SMBshares);
for(subnet=1; subnet < 255; subnet++)
{
if(NFSshares[subnet] != NULL)
{
for(j=0; j < MAXDIRS; j++)
{
if(NFSshares[subnet]->share[j] != NULL)
free(NFSshares[subnet]->share[j]);
}
free(NFSshares[subnet]);
}
}
free(NFSshares);
NIC--;
}
To:
Code: [Select]
NIC--;
}

for(subnet=1; subnet < 255; subnet++)
{
if(SMBshares[subnet] != NULL)
free(SMBshares[subnet]);
}
free(SMBshares);
for(subnet=1; subnet < 255; subnet++)
{
if(NFSshares[subnet] != NULL)
{
for(j=0; j < MAXDIRS; j++)
{
if(NFSshares[subnet]->share[j] != NULL)
free(NFSshares[subnet]->share[j]);
}
free(NFSshares[subnet]);
}
}
free(NFSshares);
These two lines are what get moved:
Code: [Select]
NIC--;
}
Let me know what happens/

Offline Scooby

  • Newbie
  • *
  • Posts: 27
Re: Is findshares open source?
« Reply #22 on: March 10, 2014, 03:24:03 PM »
New output of findshares below in code tags( when moved those two lines )
Seems I get repeated info?

I am not used to C but tried to debug following http://www.cprogramming.com/debugging/segfaults.html
It would suggest "Dereferencing an Uninitialized Pointer"

I attached file output.txt some info from gdb and strace in hope it would be useful to you
Obs! this is from the first version, no segfault in second version

Code: [Select]
Local Host Name  = alphaos
Local IP Address = 172.19.8.156 on wlan0
Local IP Address = 192.168.56.1 on vboxnet0
Local IP Address = 192.168.56.101 on vboxnet0

Samba/Windows Shares
--------------------------------------------------------------------------------
WORKGROUP
    LINUXLITE        192.168.56.102    Samba Server 3.6.3
everyoneshare                 
IPC$                           IPC Service (Samba Server 3.6.3)

Samba/Windows Shares
--------------------------------------------------------------------------------
WORKGROUP
    LINUXLITE        192.168.56.102    Samba Server 3.6.3
everyoneshare                 
IPC$                           IPC Service (Samba Server 3.6.3)

Error line 451
Samba/Windows Shares
--------------------------------------------------------------------------------
WORKGROUP
    LINUXLITE        192.168.56.102    Samba Server 3.6.3
everyoneshare                 
IPC$                           IPC Service (Samba Server 3.6.3)

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: Is findshares open source?
« Reply #23 on: March 10, 2014, 03:30:58 PM »
Hi Scooby
I was just looking through the program and realized that the fix I gave you would cause other problems. Put it back the way it
was and add a call to  InitGlobals  as shown instead.
From:
Code: [Select]
while(NIC >= 0)
{
tmp=inet_aton((char *) &NICinfo[NIC].ipaddress, (struct in_addr *) &net_ipaddress);
if(tmp < 0) bail(__LINE__);
net_ipbase=net_ipaddress & 0x00FFFFFF; // Base address in network order

if(findSMB)
{
GetShareInfoSMB();
CreateMountlistSMB();
}
To:
Code: [Select]
while(NIC >= 0)
{
InitGlobals();
tmp=inet_aton((char *) &NICinfo[NIC].ipaddress, (struct in_addr *) &net_ipaddress);
if(tmp < 0) bail(__LINE__);
net_ipbase=net_ipaddress & 0x00FFFFFF; // Base address in network order

if(findSMB)
{
GetShareInfoSMB();
CreateMountlistSMB();
}
Sorry about that. The program is fairly complex and I haven't looked at the code in 3 years.

Offline Scooby

  • Newbie
  • *
  • Posts: 27
Re: Is findshares open source?
« Reply #24 on: March 10, 2014, 03:41:28 PM »
*edit* Sorry will have no more time today. Will try in 32-bit env tomorrow
           Will take some time, have to compile vbox for it and set everything up.
            To be continued...

Tried latest, same output as with the segfault

Sorry about that. The program is fairly complex and I haven't looked at the code in 3 years.

No problems man, happy for help
and yeah it's complex for me too

I think problem is in the code segment we discussed earlier when trying to get rid off
warnings I tried our different versions with same result.
( see output.txt attached in earlier post )

I'm on 64-bit, I will now try to boot into 32-bit and see if problem will manifest there!
« Last Edit: March 10, 2014, 03:45:12 PM by Scooby »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: Is findshares open source?
« Reply #25 on: March 10, 2014, 03:43:28 PM »
Hi Scooby
Correction, You also need to add
To:
Code: [Select]
free(SMBshares);
SMBshares=NULL;
for(subnet=1; subnet < 255; subnet++)
{
if(NFSshares[subnet] != NULL)
{
for(j=0; j < MAXDIRS; j++)
{
if(NFSshares[subnet]->share[j] != NULL)
free(NFSshares[subnet]->share[j]);
}
free(NFSshares[subnet]);
}
}
free(NFSshares);
NFSshares=NULL;
NIC--;
}
Added  SMBshares=NULL;  and  NFSshares=NULL;
Actually, the problem is that memory that was allocated has to be freed and re-allocated for each additional interface
being scanned.

Offline Scooby

  • Newbie
  • *
  • Posts: 27
Re: Is findshares open source?
« Reply #26 on: March 10, 2014, 03:53:09 PM »
OK did what you asked and no segfault
But two outputs of the same share maybe cause the two entries of vboxnet0 ?

on Vbox it says

Adapter IPv4 adress: 192.168.56.1
DHCPCD Server 192.168.56.100
Host machine  192.168.56.101 ?
Linux Lite with samba share 192.168.56.102

Don't really now why network adapter has its own IP?
It comes up under ifconfig->vboxnet0 when executed on host

Maybe problem only on vbox

Now I realy got to go, Will come back tomorrow

Code: [Select]
./findshares
findshares version 1.06 Mar 8, 2014
Copyright Richard A. Rost April 23, 2011

Local Host Name  = alphaos
Local IP Address = 172.19.8.156 on wlan0
Local IP Address = 192.168.56.1 on vboxnet0
Local IP Address = 192.168.56.101 on vboxnet0

Samba/Windows Shares
--------------------------------------------------------------------------------
WORKGROUP
    LINUXLITE        192.168.56.102    Samba Server 3.6.3
everyoneshare                 
IPC$                           IPC Service (Samba Server 3.6.3)

Samba/Windows Shares
--------------------------------------------------------------------------------
WORKGROUP
    LINUXLITE        192.168.56.102    Samba Server 3.6.3
everyoneshare                 
IPC$                           IPC Service (Samba Server 3.6.3)
« Last Edit: March 10, 2014, 03:57:31 PM by Scooby »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: Is findshares open source?
« Reply #27 on: March 10, 2014, 04:08:59 PM »
Hi Scooby
Quote
Local IP Address = 192.168.56.1 on vboxnet0
Local IP Address = 192.168.56.101 on vboxnet0
Actually, I expected the same share to be reported twice, once by each of the listed interfaces. I guess I'll have to add a
message to the output to make that apparent.

I'm afraid I don't really know anything about vbox. Whatever interfaces the operating system reports as available are listed
and scanned.

Offline Scooby

  • Newbie
  • *
  • Posts: 27
Re: Is findshares open source?
« Reply #28 on: March 11, 2014, 05:41:37 AM »
Actually, I expected the same share to be reported twice, once by each of the listed interfaces. I guess I'll have to add a
message to the output to make that apparent.

Well that seems logical and with added message to output it would be more user friendly.

It probably only shows up in Vbox right?

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: Is findshares open source?
« Reply #29 on: March 11, 2014, 01:31:07 PM »
Hi Scooby
Quote
... and with added message to output it would be more user friendly.
I was going to go with user hostile, but your way is good too. ;D
I managed to get the wireless connection on my laptop to work so I could test with multiple NICs. Here is what the output
currently looks like:
Code: [Select]
findshares version 1.06 Mar 11, 2014
Copyright Richard A. Rost April 23, 2011

Local Host Name  = box
Local IP Address = 192.168.1.45 on eth0
Local IP Address = 192.168.2.55 on eth0:1
Local IP Address = 192.168.1.77 on eth0:2
Local IP Address = 10.0.0.3 on eth1

Scanning from 10.0.0.3 on eth1
No shares found

Scanning from 192.168.1.77 on eth0:2
Samba/Windows Shares
--------------------------------------------------------------------------------
MYGROUP
    BITBUCKET        192.168.1.47      TC Samba Server
        public                         Usable by all
        smalldrive                     Temporary workspace
        IPC$                           IPC Service (TC Samba Server)


Server          Remote Resource        Local Mount Point
--------------------------------------------------------------------------------
192.168.1.47    public                 /mnt/bb


Scanning from 192.168.2.55 on eth0:1
No shares found

Scanning from 192.168.1.45 on eth0
Samba/Windows Shares
--------------------------------------------------------------------------------
MYGROUP
    BITBUCKET        192.168.1.47      TC Samba Server
        public                         Usable by all
        smalldrive                     Temporary workspace
        IPC$                           IPC Service (TC Samba Server)


Server          Remote Resource        Local Mount Point
--------------------------------------------------------------------------------
192.168.1.47    public                 /mnt/bb
I've updated the attachment in reply #19 with the current changes, let me know what you think.

Quote
It probably only shows up in Vbox right?
Actually, you can bind multiple IPs to a NIC as illustrated in the output above.