Ubuntu Samba – Read-Write-FSTAB-Cifs-Mount


This is my current setup for my two Ubuntu 10.10 (Maverick Meerkat) boxes. One shares a read/write folder to the other. This is my setup. I think the key to this is having the same username on both computers having access to the files.

You might have to run this on the the folder:
sudo chmod -R 777 /path/to/files
sudo chown -R usernameonbothcomputers:usernameonbothcomputers /path/to/files

I installed samba by doing: sudo apt-get install samba

/etc/samba/smb.conf : (on the computer serving the files)

[global]
	workgroup = WORKGROUP
	server string = %h server (Samba, Ubuntu)
	dns proxy = no
 
	interfaces = 127.0.0.0/8 eth0
	bind interfaces only = yes
 
	log file = /var/log/samba/log.%m
	max log size = 1000
	syslog = 0
 
	panic action = /usr/share/samba/panic-action %d
	encrypt passwords = true
	passdb backend = tdbsam
	obey pam restrictions = yes
	unix password sync = yes
	passwd program = /usr/bin/passwd %u
	passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
	pam password change = yes
 
	guest account = nobody
	invalid users = root
	usershare allow guests = yes
 
[MyFiles]
	path = /path/to/share
	writable = yes
	read only = no
	valid users = usernameonbothcomputers

sudo /etc/init.d/smbd reload

/etc/fstab : (on the computer accessing the files)

//SAMBASHAREsSERVERNAME/MyFiles /path/to/mount cifs users,,noatime,username=usernameonbothcomputers,password=theuserspassword 0 0

You should be able to run this to mount all things in your fstab:
sudo mount -a

.Net – Sending Email with In Memory Attachment

This VB.Net code takes the FileUpload control’s PostedFile and without saving it to the filesystem attaches it to an MailMessage and sends an email.

Advantages:

  • No threading, read/write permissions needed.
  • One line of code.

Front End:

<asp:FileUpload ID="fileUpload" runat="server" />

Code:

Dim m As New MailMessage()
m.Attachments.Add(New Attachment(fileUpload.PostedFile.InputStream, fileUpload.FileName))