Friday, September 27, 2013

Samba Centos root share error - You do not have permission to access in windows

Description:

You have a Centos PC and trying to access the root user's Desktop from a Windows PC. You can see the shared folder in the \Network\Centos_PC_IP, but can't access the folder when you double click.

The pop window arise with a error -

You do not have permission to access in windows \\CENTOS_IP\\root. Contact your network administrator to request access.





Solution: 

First you need to check you samba settings in your centos pc by command -
 
testparm
 
After that you need to do a little change o your /etc/samba/smb.conf file.

Find the folder you shared from root in this file.

It will be like --

        [root]
        path = /root/Desktop
        read only = No 

Change it to -

        [root] 
        force user = root
        force group = root 
        path = /root/Desktop
        read only = No 

 And restart the samba by --

        /sbin/service smb restart
 
And you are done!


[Solved by Abdullah Al Mamun @ Eyeball Networks Inc]

Thursday, September 26, 2013

How to share (read/write) any folder with root permissions in centos 6 or linux

Question:

Now a days many people like software developers uses 2 or more OS. So the people who have multiple PC's with different OS need to share the files or folder between them. So how?


Solution:

Requirement:

i.  Samba
ii. LAN connection

Step 1. Install samba by giving command in centos console -
 
                           yum install samba

Step 2. Configure samba by opening smb.conf 

                           vi /etc/samba/smb.conf

i. Create a workgroup in which you are going to share the files/folders.

by default it is like -

                  workgroup = MYGROUP
change it to -
                                

netbios name = your_host_name 
workgroup = workgroup

because windows system has default group named as WORKGROUP.

ii. Now create a shared resource , where you will indicate the path of the folder you want to share.

        [myshare]
        path = /root/Desktop/share
        writeable = yes 
Where [myshare] is the folder name what you want people to see in their PC.
"path" is the path of your shared folder.

Step 3. Make sure your firewall allows SAMBA.

Step 4. Now test the settings of SAMBA by --

# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: rlimit_max (1024) below minimum Windows limit (16384)
Processing section "[myshare]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
Step 5. Disable SELinux by-      
setenforce 0

        To permanently set it modify the /etc/selinux/config file and set the value of -

SELINUX = permissive

Step 6. Restart SAMBA by -

/sbin/service smb restart


Now you are done!



 
 

Tuesday, September 3, 2013

How to start or open new activity or window from one window on button click

Requirement: You want to make an "app", which displays a login screen, and users can log in. If the login is correct,  open a new window, where users can do other staff. Then how can you do this?


Ans:

Step 1. Create a layout xml for the new window. In my case I have created one
named newwindow.xml . The entry are as follows --

<?xml version="1.0" encoding="utf-8"?>
<Gallery xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#9999FF" >
   </Gallery>

Step 2. Create a class with extending Activity .

Step 3. On that new class add --

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.newwindow);
    }

Here newwindow is the layout xml.

Start Up window is given bellow --




















Step 4. Add the new class on AndroidManifest.xml


Note that, if you don't add the class on AndroidManifest.xml app will crash ("the app stopped unexpectedly").


Step 5. Now add the following where you want to initiate this new activity or window ---


Intent intent = new Intent(getApplicationContext(), NewWindow.class);
                    startActivity(intent);
 That's all!


Now If you add it on button click then the output will be --

You can see that the new windows background colour is "#9999FF" .


The constructor Intent(new View.OnClickListener()) is undefined

Issue:
The constructor Intent(new View.OnClickListener(){}, Class<NewWindow>) is undefined.



Solution: Find out --

Intent intent = new Intent(this, NewWindow.class);

Change the this to getApplicationContext() or StartClass.this .

 

How to add button action for multiple button in android

In android it is extreme necessary to use button and do many thing on click or touch of this button.

So how you can do this ?


Ans:   It's pretty simple!

Just find out the -- findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener);

It is generated by default in new android sdk. The bold portion is the touch listener for button which is implemented on bellow of your main activity class.
You can do your thing on overriden function OnTouch.


If you want to do it for click and many button here is the way --

findViewById(R.id.dummy_button).setOnClickListener(ButtonListener);

View.OnClickListener ButtonListener = new View.OnClickListener(){

        public void onClick(View view) {
            switch (view.getId()) {

                case R.id.dummy_button:
                      setContentView(R.layout.newwindow);
                      break;
                case R.id.dummy_button1:
                      setContentView(R.layout.newwindow1);
                      break;
                case R.id.dummy_button2:
                      setContentView(R.layout.newwindow2);
                      break;
  
                  }
        }

    };

newwindow,
newwindow1,
newwindow2

are the layouts .

How to Generate and use the ssh key on Gerrit, github.io, gitlab, and bitbucket.

 Details can be found here -