Changeset - 909353f139a6
[Not reviewed]
default
0 1 0
ethanzonca - 16 years ago 2009-08-01 18:27:02

Removed int_to_char(), left stub
1 file changed with 2 insertions and 26 deletions:
0 comments (0 inline, 0 general)
src/server/slavefuncs.c
Show inline comments
 
@@ -12,76 +12,52 @@
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU Affero General Public License for more details.
 

	
 
  You should have received a copy of the GNU Affero General Public License
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
 /*
 
  * Registration on server. Needs attention. Prevent account spamming.
 
  * distrenslave -c username email@example.com
 
 */
 

	
 
#include "slavefuncs.h"
 
#include "blendjob.h"
 
#include "execio.h"
 

	
 
#include <stdio.h>
 
#include <string.h>
 
#include <unistd.h>
 
#include <stdlib.h>
 
#include <sys/stat.h>
 
#include <fcntl.h>
 

	
 
/** Converts an integer to a string, in ANSI C, thanks to Dom_ (http://www.signalsondisplay.com/) */
 
/** Converts an integer to a string, currently a stub. */
 
char *int_to_str(int nbr)
 
{
 
  int   div;
 
  int   len;
 
  int   i;
 
  char  *res;
 
  res = malloc(4 * sizeof(*res)); // Was xmalloc, hopefully it still works :D
 
  i = 0;
 
  while (i < 3)
 
    res[i++] = '\0';
 
  res[3] = '\0';
 
  i = 0;
 
  div = 1;
 
  len = 1;
 
  while (nbr / div >= 10)
 
    {
 
      div *= 10;
 
      len++;
 
    }
 
  while (len)
 
    {
 
      res[i++] = '0' + (nbr / div);
 
      len--;
 
      nbr %= div;
 
      div /= 10;
 
    }
 
  return (res);
 
 return;
 
}
 

	
 
/** Generates a SSH key with ssh-keygen */
 
int ssh_keygen(){
 
	/* Checks to see if the keys are already present. */
 
	int status;
 
	struct stat buffer;
 
	status = stat(SYSCONFDIR "/distren.id_rsa", &buffer);
 
	if(status != -1){
 
		fprintf(stderr, "***Please delete etc/distren.id_rsa and etc/distren.id_rsa.pub to register.\n");
 
		return 0;
 
	}
 

	
 
	/* start execio code */
 
	char *command = "ssh-keygen"; // @TODO: append .exe if win32?
 
	int ret;
 
	char *cmd[] = { command, "-q", "-f", SYSCONFDIR "/distren.id_rsa", "-N", "", (char *)NULL }; // TODO: Give me the correct args!
 
	char buf[10];
 
	struct execio *testrem;
 
	size_t readlen;
 
	ret = execio_open(&testrem, command, cmd); // This path will be absolute for testing, should be relative to install on production
 
	buf[9] = '\0'; // null-terminating the array...
 
	while(!execio_read(testrem, buf, 9, &readlen))
 
	    {
0 comments (0 inline, 0 general)